{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ab044e14",
   "metadata": {},
   "source": [
    "# 数据结构"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5a927ae1",
   "metadata": {},
   "source": [
    "## Series\n",
    "一维数据，用列表生成 Series时，Pandas 默认自动生成整数索引，也可以指定索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "10eee18b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    0\n",
       "b    3\n",
       "c    5\n",
       "d    7\n",
       "dtype: int64"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "s = pd.Series(data = [0,3,5,7],index = ['a','b','c','d'])\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9c10f526",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0\n",
       "1    3\n",
       "2    5\n",
       "3    7\n",
       "dtype: int64"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = pd.Series(data = [0,3,5,7]) # 不指定索引，默认\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7424bab9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       0.0\n",
       "1       1.0\n",
       "2       7.0\n",
       "3       9.0\n",
       "4       NaN\n",
       "5       NaN\n",
       "6    1024.0\n",
       "7     512.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "l = [0, 1, 7, 9, np.NAN, None, 1024, 512]\n",
    "\n",
    "# 无论是 numpy中的 NAN 还是 Python中的 None 在pandas中都以缺失数据 NaN对待\n",
    "s1 = pd.Series(data=l)  # pandas自动添加索引\n",
    "s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b780feb2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a       0.0\n",
       "b       1.0\n",
       "c       7.0\n",
       "d       9.0\n",
       "e       NaN\n",
       "f       NaN\n",
       "h    1024.0\n",
       "i     512.0\n",
       "dtype: float32"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2 = pd.Series(data=l, index=list('abcdefhi'), dtype='float32')  # 指定行索引\n",
    "s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "da0dddd2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a     99\n",
       "b    137\n",
       "c    149\n",
       "Name: Python_score, dtype: int64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 传入字典创建，key行索引\n",
    "s3 = pd.Series(data={'a': 99, 'b': 137, 'c': 149}, name='Python_score')\n",
    "s3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bcd3ad9b",
   "metadata": {},
   "source": [
    "## DataFrame\n",
    "二维结构，DataFrame是由多种类型的列构成的二维标签数据结构，类似于 Excel 、SQL 表，或 Series 对象构成的字典。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4b6037fb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>En</th>\n",
       "      <th>Math</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>67.0</td>\n",
       "      <td>32.0</td>\n",
       "      <td>59.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>11.0</td>\n",
       "      <td>80.0</td>\n",
       "      <td>138.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>118.0</td>\n",
       "      <td>119.0</td>\n",
       "      <td>28.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>25.0</td>\n",
       "      <td>82.0</td>\n",
       "      <td>144.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>32.0</td>\n",
       "      <td>61.0</td>\n",
       "      <td>16.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python     En   Math\n",
       "A    67.0   32.0   59.0\n",
       "B    11.0   80.0  138.0\n",
       "C   118.0  119.0   28.0\n",
       "D    25.0   82.0  144.0\n",
       "E    32.0   61.0   16.0"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(data=np.random.randint(0, 150, size=(5, 3)), # 生成 5*3的 数据\n",
    "             columns=['Python', 'En', 'Math'], # 列索引\n",
    "             index=list('ABCDE'), dtype=np.float32) # 行索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "81b77380",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['A', 'B', 'C', 'D', 'E']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 字符串 -> list\n",
    "list('ABCDE')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "49984f80",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>En</th>\n",
       "      <th>Math</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>126</td>\n",
       "      <td>66</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>101</td>\n",
       "      <td>107</td>\n",
       "      <td>138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>114</td>\n",
       "      <td>141</td>\n",
       "      <td>105</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>112</td>\n",
       "      <td>74</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>130</td>\n",
       "      <td>35</td>\n",
       "      <td>118</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python   En  Math\n",
       "A     126   66    60\n",
       "B     101  107   138\n",
       "C     114  141   105\n",
       "D     112   74    37\n",
       "E     130   35   118"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建DataFrame第二种方式，字典中的key 作为列索引\n",
    "df = pd.DataFrame(data={'Python': np.random.randint(100, 150, size=5),\n",
    "                        'En': np.random.randint(0, 150, size=5),\n",
    "                        'Math': np.random.randint(0, 150, size=5)}, # 列索引 和 数据\n",
    "                  index=list('ABCDE')) # 行索引\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "39e1e187",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>En</th>\n",
       "      <th>Math</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>130</td>\n",
       "      <td>35</td>\n",
       "      <td>118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>112</td>\n",
       "      <td>74</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>114</td>\n",
       "      <td>141</td>\n",
       "      <td>105</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>101</td>\n",
       "      <td>107</td>\n",
       "      <td>138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>126</td>\n",
       "      <td>66</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python   En  Math\n",
       "E     130   35   118\n",
       "D     112   74    37\n",
       "C     114  141   105\n",
       "B     101  107   138\n",
       "A     126   66    60"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 行索引，降序排序\n",
    "df.sort_index(ascending = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "fee7be2e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>En</th>\n",
       "      <th>Math</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>129</td>\n",
       "      <td>73</td>\n",
       "      <td>95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>123</td>\n",
       "      <td>129</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>100</td>\n",
       "      <td>16</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>116</td>\n",
       "      <td>20</td>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>139</td>\n",
       "      <td>53</td>\n",
       "      <td>136</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python   En  Math\n",
       "1     129   73    95\n",
       "2     123  129    32\n",
       "3     100   16    11\n",
       "4     116   20    80\n",
       "5     139   53   136"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建DataFrame第二种方式，字典中的key作为列索引\n",
    "df = pd.DataFrame(data={'Python': np.random.randint(100, 150, size=5),\n",
    "                        'En': np.random.randint(0, 150, size=5),\n",
    "                        'Math': np.random.randint(0, 150, size=5)}, # 列索引 和 数据\n",
    "                  index=np.arange(1, 6)) # 行索引\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b6ab39db",
   "metadata": {},
   "source": [
    "# 数据查看\n",
    "查看DataFrame的常用属性 和 DataFrame的概览和统计信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f8a36744",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 创建 DataFrame\n",
    "df = pd.DataFrame(data=np.random.randint(0, 151, size=(150, 3)),\n",
    "                  index=None,  # 行索引默认\n",
    "                  columns=['Python', 'Math', 'En'])  # 列索引\n",
    "\n",
    "# 转变Python列的 数据类型\n",
    "df['Python'] = df['Python'].astype(np.int64)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "473c65c0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>132</td>\n",
       "      <td>12</td>\n",
       "      <td>124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>14</td>\n",
       "      <td>122</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>40</td>\n",
       "      <td>101</td>\n",
       "      <td>110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>18</td>\n",
       "      <td>127</td>\n",
       "      <td>64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>142</td>\n",
       "      <td>77</td>\n",
       "      <td>69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>79</td>\n",
       "      <td>50</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>101</td>\n",
       "      <td>64</td>\n",
       "      <td>87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>106</td>\n",
       "      <td>42</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>22</td>\n",
       "      <td>2</td>\n",
       "      <td>95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>57</td>\n",
       "      <td>43</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>150 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Python  Math   En\n",
       "0       132    12  124\n",
       "1        14   122   60\n",
       "2        40   101  110\n",
       "3        18   127   64\n",
       "4       142    77   69\n",
       "..      ...   ...  ...\n",
       "145      79    50   44\n",
       "146     101    64   87\n",
       "147     106    42   31\n",
       "148      22     2   95\n",
       "149      57    43   70\n",
       "\n",
       "[150 rows x 3 columns]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "4143d00d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>132</td>\n",
       "      <td>12</td>\n",
       "      <td>124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>14</td>\n",
       "      <td>122</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>40</td>\n",
       "      <td>101</td>\n",
       "      <td>110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>18</td>\n",
       "      <td>127</td>\n",
       "      <td>64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>142</td>\n",
       "      <td>77</td>\n",
       "      <td>69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>77</td>\n",
       "      <td>98</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>36</td>\n",
       "      <td>56</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>41</td>\n",
       "      <td>75</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>40</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>33</td>\n",
       "      <td>9</td>\n",
       "      <td>107</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Math   En\n",
       "0     132    12  124\n",
       "1      14   122   60\n",
       "2      40   101  110\n",
       "3      18   127   64\n",
       "4     142    77   69\n",
       "5      77    98   62\n",
       "6      36    56    0\n",
       "7      41    75   62\n",
       "8      40     8    8\n",
       "9      33     9  107"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查看其属性、概览和统计信息\n",
    "df.head(10)  # 显示头部 10行，默认5个"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "dddb6a2d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>79</td>\n",
       "      <td>50</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>101</td>\n",
       "      <td>64</td>\n",
       "      <td>87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>106</td>\n",
       "      <td>42</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>22</td>\n",
       "      <td>2</td>\n",
       "      <td>95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>57</td>\n",
       "      <td>43</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     Python  Math  En\n",
       "145      79    50  44\n",
       "146     101    64  87\n",
       "147     106    42  31\n",
       "148      22     2  95\n",
       "149      57    43  70"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.tail()  # 显示末尾5行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "d9c98c90",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(150, 3)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape  # 查看形状，行数和列数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "99879808",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Python    int64\n",
       "Math      int64\n",
       "En        int64\n",
       "dtype: object"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes  # 查看数据类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "fe05ad5d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RangeIndex(start=0, stop=150, step=1)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index  # 行索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "77224470",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Python', 'Math', 'En'], dtype='object')"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns  # 列索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "a03a648b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[132,  12, 124],\n",
       "       [ 14, 122,  60],\n",
       "       [ 40, 101, 110],\n",
       "       [ 18, 127,  64],\n",
       "       [142,  77,  69],\n",
       "       [ 77,  98,  62],\n",
       "       [ 36,  56,   0],\n",
       "       [ 41,  75,  62],\n",
       "       [ 40,   8,   8],\n",
       "       [ 33,   9, 107],\n",
       "       [133,  77,  27],\n",
       "       [118, 102,  83],\n",
       "       [ 53,  66,  68],\n",
       "       [ 50,   7, 137],\n",
       "       [ 51, 140, 138],\n",
       "       [ 38,  16, 139],\n",
       "       [108,  66, 143],\n",
       "       [ 18, 115,  66],\n",
       "       [123, 132,  20],\n",
       "       [ 58, 137,  70],\n",
       "       [ 24,  26,  38],\n",
       "       [ 67,   5,  89],\n",
       "       [125, 140,  25],\n",
       "       [ 50,  81,  88],\n",
       "       [106,   5,  73],\n",
       "       [ 47,  76,  78],\n",
       "       [ 76,   2, 145],\n",
       "       [  9,  60,  74],\n",
       "       [ 99,  27,  45],\n",
       "       [ 96,  91,  27],\n",
       "       [137, 138, 125],\n",
       "       [116,  34,  76],\n",
       "       [ 36, 127, 123],\n",
       "       [ 31,  20,  25],\n",
       "       [133,  88,  88],\n",
       "       [ 57,  45,  90],\n",
       "       [113,  35,  56],\n",
       "       [ 67,  71, 105],\n",
       "       [ 16,  63,  44],\n",
       "       [ 51, 124,  26],\n",
       "       [ 20,  57, 136],\n",
       "       [123,  27,  28],\n",
       "       [ 81, 100, 127],\n",
       "       [111, 145,  41],\n",
       "       [ 12,  93, 148],\n",
       "       [ 71,  77, 126],\n",
       "       [104,   4,  41],\n",
       "       [ 50, 116, 142],\n",
       "       [ 96,  76,  28],\n",
       "       [144,  46,  37],\n",
       "       [135, 140, 134],\n",
       "       [ 62,  74,  79],\n",
       "       [123,  91,  73],\n",
       "       [ 54, 102, 102],\n",
       "       [ 71,  99,  10],\n",
       "       [120,  68,  76],\n",
       "       [115, 104,  39],\n",
       "       [129,  74, 138],\n",
       "       [ 16,  71, 122],\n",
       "       [122,   1, 115],\n",
       "       [ 50, 120,  94],\n",
       "       [108, 112, 101],\n",
       "       [137,  30,  43],\n",
       "       [  1,  47, 122],\n",
       "       [ 88,  42, 133],\n",
       "       [146,  14,  87],\n",
       "       [141,  60,   6],\n",
       "       [119,  43,  83],\n",
       "       [ 12,  98,  18],\n",
       "       [ 78,  61,  62],\n",
       "       [ 68, 119,  69],\n",
       "       [112,  38, 140],\n",
       "       [ 80,  39,  59],\n",
       "       [134,  40,  27],\n",
       "       [147,  88,  28],\n",
       "       [ 41, 118,  86],\n",
       "       [ 40,  73,  26],\n",
       "       [ 33, 137,  64],\n",
       "       [ 50,  49,  99],\n",
       "       [ 85, 114, 106],\n",
       "       [149,  90,  89],\n",
       "       [ 33,  14,  59],\n",
       "       [111,  42,  72],\n",
       "       [ 17,  64, 130],\n",
       "       [ 79,  96,  68],\n",
       "       [ 61,  49,  83],\n",
       "       [ 62, 108,  24],\n",
       "       [ 75,  16, 108],\n",
       "       [ 97,  28, 102],\n",
       "       [ 62, 117,  80],\n",
       "       [ 95, 115, 145],\n",
       "       [ 63,  37,  81],\n",
       "       [143,  67,  78],\n",
       "       [103, 115,  89],\n",
       "       [128,  55, 114],\n",
       "       [ 38,  71,  95],\n",
       "       [ 42,  45,  87],\n",
       "       [ 16, 131,  13],\n",
       "       [150,  88,  36],\n",
       "       [ 84,  46,  84],\n",
       "       [136,  38, 135],\n",
       "       [126,   3,  95],\n",
       "       [119,  68,   4],\n",
       "       [114,  29, 100],\n",
       "       [ 78, 121,  62],\n",
       "       [131, 113,  31],\n",
       "       [ 61, 112,  64],\n",
       "       [ 60,  94,  85],\n",
       "       [141, 128,  11],\n",
       "       [144,  81,  10],\n",
       "       [106,  60,  35],\n",
       "       [ 54, 109,  43],\n",
       "       [ 58, 127, 111],\n",
       "       [109, 131,  72],\n",
       "       [ 61, 101, 137],\n",
       "       [116,  87, 112],\n",
       "       [150,   3,  15],\n",
       "       [130,  71,   0],\n",
       "       [107,  88,  54],\n",
       "       [ 52, 139,  59],\n",
       "       [124,  38,  30],\n",
       "       [ 95,  96,  61],\n",
       "       [ 69,  99, 101],\n",
       "       [ 21, 134,  54],\n",
       "       [  3,  61, 113],\n",
       "       [116, 127, 121],\n",
       "       [ 69, 109,  61],\n",
       "       [100,  30, 150],\n",
       "       [129,  47, 140],\n",
       "       [ 51,  47,  87],\n",
       "       [ 41, 138,  66],\n",
       "       [ 56,  87,  51],\n",
       "       [138,  84,  67],\n",
       "       [ 49,  41,  10],\n",
       "       [ 52,  38, 111],\n",
       "       [110,  13, 116],\n",
       "       [ 69, 100, 127],\n",
       "       [ 88,  31,  84],\n",
       "       [ 38, 106,  54],\n",
       "       [131, 121, 105],\n",
       "       [ 98, 110,  21],\n",
       "       [ 12, 105, 107],\n",
       "       [ 87,  64,  47],\n",
       "       [ 14,  31, 107],\n",
       "       [124, 114, 131],\n",
       "       [ 79,  50,  44],\n",
       "       [101,  64,  87],\n",
       "       [106,  42,  31],\n",
       "       [ 22,   2,  95],\n",
       "       [ 57,  43,  70]])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.values  # 对象值，二维ndarray数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "b6b7dd76",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>150.000000</td>\n",
       "      <td>150.000000</td>\n",
       "      <td>150.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>80.786667</td>\n",
       "      <td>73.846667</td>\n",
       "      <td>76.753333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>41.463591</td>\n",
       "      <td>40.154523</td>\n",
       "      <td>39.892126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>50.000000</td>\n",
       "      <td>42.000000</td>\n",
       "      <td>44.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>78.500000</td>\n",
       "      <td>74.000000</td>\n",
       "      <td>77.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>117.500000</td>\n",
       "      <td>108.750000</td>\n",
       "      <td>107.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>150.000000</td>\n",
       "      <td>145.000000</td>\n",
       "      <td>150.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           Python        Math          En\n",
       "count  150.000000  150.000000  150.000000\n",
       "mean    80.786667   73.846667   76.753333\n",
       "std     41.463591   40.154523   39.892126\n",
       "min      1.000000    1.000000    0.000000\n",
       "25%     50.000000   42.000000   44.000000\n",
       "50%     78.500000   74.000000   77.000000\n",
       "75%    117.500000  108.750000  107.000000\n",
       "max    150.000000  145.000000  150.000000"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()  # 查看数值型列的汇总统计, 计数、平均值、标准差、最小值、四分位数、最大值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "76679c84",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 150 entries, 0 to 149\n",
      "Data columns (total 3 columns):\n",
      " #   Column  Non-Null Count  Dtype\n",
      "---  ------  --------------  -----\n",
      " 0   Python  150 non-null    int64\n",
      " 1   Math    150 non-null    int64\n",
      " 2   En      150 non-null    int64\n",
      "dtypes: int64(3)\n",
      "memory usage: 3.6 KB\n"
     ]
    }
   ],
   "source": [
    "df.info()  # 查看列索引、数据类型、非空计数和内存信息"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8df5073",
   "metadata": {},
   "source": [
    "# 数据输入和输出"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "99fbbec3",
   "metadata": {},
   "source": [
    "## CSV文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "b795219b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>IT</th>\n",
       "      <th>化工</th>\n",
       "      <th>生物</th>\n",
       "      <th>教师</th>\n",
       "      <th>士兵</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>48</td>\n",
       "      <td>30</td>\n",
       "      <td>41</td>\n",
       "      <td>28</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>2</td>\n",
       "      <td>21</td>\n",
       "      <td>6</td>\n",
       "      <td>15</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>45</td>\n",
       "      <td>19</td>\n",
       "      <td>39</td>\n",
       "      <td>37</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>34</td>\n",
       "      <td>5</td>\n",
       "      <td>25</td>\n",
       "      <td>28</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>45</td>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "      <td>49</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   IT  化工  生物  教师  士兵\n",
       "A  48  30  41  28  31\n",
       "B   2  21   6  15  36\n",
       "C  45  19  39  37  33\n",
       "D  34   5  25  28  42\n",
       "E  45   8   1  49  25"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = pd.DataFrame(data=np.random.randint(0, 50, size=[5, 5]),  # 薪资情况\n",
    "                  columns=['IT', '化工', '生物', '教师', '士兵'], \n",
    "                  index=list('ABCDE'))\n",
    "\n",
    "display(df)\n",
    "# 保存到当前路径下，文件命名是：salary.csv。csv逗号分割值文件格式\n",
    "df.to_csv('./data/salary.csv',\n",
    "          sep=',',  # 文本分隔符，默认是逗号\n",
    "          header=True,  # 是否保存列索引\n",
    "          index=True)  # 是否保存行索引 -- 保存行索引，文件被加载时，默认行索引会作为一列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "f2c19579",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>IT</th>\n",
       "      <th>化工</th>\n",
       "      <th>生物</th>\n",
       "      <th>教师</th>\n",
       "      <th>士兵</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>48</td>\n",
       "      <td>30</td>\n",
       "      <td>41</td>\n",
       "      <td>28</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>2</td>\n",
       "      <td>21</td>\n",
       "      <td>6</td>\n",
       "      <td>15</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>45</td>\n",
       "      <td>19</td>\n",
       "      <td>39</td>\n",
       "      <td>37</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>34</td>\n",
       "      <td>5</td>\n",
       "      <td>25</td>\n",
       "      <td>28</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>45</td>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "      <td>49</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   IT  化工  生物  教师  士兵\n",
       "A  48  30  41  28  31\n",
       "B   2  21   6  15  36\n",
       "C  45  19  39  37  33\n",
       "D  34   5  25  28  42\n",
       "E  45   8   1  49  25"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 加载\n",
    "pd.read_csv('./data/salary.csv',\n",
    "            sep = ',', # 默认是逗号\n",
    "            header = [0], # 指定列索引\n",
    "            index_col=0)  # 指定行索引"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "be967b3d",
   "metadata": {},
   "source": [
    "## Excel"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "4d913a1f",
   "metadata": {},
   "outputs": [],
   "source": [
    "df1 = pd.DataFrame(data=np.random.randint(0, 50, size=[50, 5]),  # 薪资情况\n",
    "                   columns=['IT', '化工', '生物', '教师', '士兵'])\n",
    "\n",
    "df2 = pd.DataFrame(data=np.random.randint(0, 50, size=[150, 3]),  # 计算机科目的考试成绩\n",
    "                   columns=['Python', 'Tensorflow', 'Keras'])\n",
    "\n",
    "\n",
    "# 保存到当前路径下，文件命名是：salary.xls\n",
    "df1.to_excel('./data/salary.xlsx',\n",
    "             sheet_name='salary',  # Excel中工作表的名字\n",
    "             header=True,  # 是否保存列索引\n",
    "             index=False)  # 是否保存行索引\n",
    "\n",
    "# 第二个工作表 会覆盖 第一个工作表\n",
    "df2.to_excel('./data/salary.xlsx',\n",
    "             sheet_name='kaoshi',  # Excel中工作表的名字\n",
    "             header=True,  # 是否保存列索引\n",
    "             index=False)  # 是否保存行索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "fa4cc9f7",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "Worksheet named 'salary' not found",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[0;32mIn [25]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[38;5;66;03m# 读取 Excel表格 -- error: salary表格被覆盖了\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_excel\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m./data/salary.xlsx\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m      3\u001b[0m \u001b[43m              \u001b[49m\u001b[43msheet_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43msalary\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# 读取哪一个工作表，默认第一个\u001b[39;49;00m\n\u001b[1;32m      4\u001b[0m \u001b[43m              \u001b[49m\u001b[43mheader\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# 使用第一行数据作为列索引\u001b[39;49;00m\n\u001b[1;32m      5\u001b[0m \u001b[43m              \u001b[49m\u001b[43mnames\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;28;43mlist\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mABCDE\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# 替换列索引\u001b[39;49;00m\n\u001b[1;32m      6\u001b[0m \u001b[43m              \u001b[49m\u001b[43mindex_col\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m3\u001b[39;49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/util/_decorators.py:311\u001b[0m, in \u001b[0;36mdeprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m    305\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(args) \u001b[38;5;241m>\u001b[39m num_allow_args:\n\u001b[1;32m    306\u001b[0m     warnings\u001b[38;5;241m.\u001b[39mwarn(\n\u001b[1;32m    307\u001b[0m         msg\u001b[38;5;241m.\u001b[39mformat(arguments\u001b[38;5;241m=\u001b[39marguments),\n\u001b[1;32m    308\u001b[0m         \u001b[38;5;167;01mFutureWarning\u001b[39;00m,\n\u001b[1;32m    309\u001b[0m         stacklevel\u001b[38;5;241m=\u001b[39mstacklevel,\n\u001b[1;32m    310\u001b[0m     )\n\u001b[0;32m--> 311\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/io/excel/_base.py:465\u001b[0m, in \u001b[0;36mread_excel\u001b[0;34m(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, thousands, decimal, comment, skipfooter, convert_float, mangle_dupe_cols, storage_options)\u001b[0m\n\u001b[1;32m    459\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m    460\u001b[0m         \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mEngine should not be specified when passing \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m    461\u001b[0m         \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124man ExcelFile - ExcelFile already has the engine set\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m    462\u001b[0m     )\n\u001b[1;32m    464\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 465\u001b[0m     data \u001b[38;5;241m=\u001b[39m \u001b[43mio\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparse\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    466\u001b[0m \u001b[43m        \u001b[49m\u001b[43msheet_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msheet_name\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    467\u001b[0m \u001b[43m        \u001b[49m\u001b[43mheader\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mheader\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    468\u001b[0m \u001b[43m        \u001b[49m\u001b[43mnames\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnames\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    469\u001b[0m \u001b[43m        \u001b[49m\u001b[43mindex_col\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindex_col\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    470\u001b[0m \u001b[43m        \u001b[49m\u001b[43musecols\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43musecols\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    471\u001b[0m \u001b[43m        \u001b[49m\u001b[43msqueeze\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msqueeze\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    472\u001b[0m \u001b[43m        \u001b[49m\u001b[43mdtype\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdtype\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    473\u001b[0m \u001b[43m        \u001b[49m\u001b[43mconverters\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconverters\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    474\u001b[0m \u001b[43m        \u001b[49m\u001b[43mtrue_values\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtrue_values\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    475\u001b[0m \u001b[43m        \u001b[49m\u001b[43mfalse_values\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfalse_values\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    476\u001b[0m \u001b[43m        \u001b[49m\u001b[43mskiprows\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mskiprows\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    477\u001b[0m \u001b[43m        \u001b[49m\u001b[43mnrows\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnrows\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    478\u001b[0m \u001b[43m        \u001b[49m\u001b[43mna_values\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mna_values\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    479\u001b[0m \u001b[43m        \u001b[49m\u001b[43mkeep_default_na\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkeep_default_na\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    480\u001b[0m \u001b[43m        \u001b[49m\u001b[43mna_filter\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mna_filter\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    481\u001b[0m \u001b[43m        \u001b[49m\u001b[43mverbose\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mverbose\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    482\u001b[0m \u001b[43m        \u001b[49m\u001b[43mparse_dates\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparse_dates\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    483\u001b[0m \u001b[43m        \u001b[49m\u001b[43mdate_parser\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdate_parser\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    484\u001b[0m \u001b[43m        \u001b[49m\u001b[43mthousands\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mthousands\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    485\u001b[0m \u001b[43m        \u001b[49m\u001b[43mdecimal\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdecimal\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    486\u001b[0m \u001b[43m        \u001b[49m\u001b[43mcomment\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcomment\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    487\u001b[0m \u001b[43m        \u001b[49m\u001b[43mskipfooter\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mskipfooter\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    488\u001b[0m \u001b[43m        \u001b[49m\u001b[43mconvert_float\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconvert_float\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    489\u001b[0m \u001b[43m        \u001b[49m\u001b[43mmangle_dupe_cols\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmangle_dupe_cols\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    490\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    491\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[1;32m    492\u001b[0m     \u001b[38;5;66;03m# make sure to close opened file handles\u001b[39;00m\n\u001b[1;32m    493\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m should_close:\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/io/excel/_base.py:1458\u001b[0m, in \u001b[0;36mExcelFile.parse\u001b[0;34m(self, sheet_name, header, names, index_col, usecols, squeeze, converters, true_values, false_values, skiprows, nrows, na_values, parse_dates, date_parser, thousands, comment, skipfooter, convert_float, mangle_dupe_cols, **kwds)\u001b[0m\n\u001b[1;32m   1424\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mparse\u001b[39m(\n\u001b[1;32m   1425\u001b[0m     \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m   1426\u001b[0m     sheet_name: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m|\u001b[39m \u001b[38;5;28mint\u001b[39m \u001b[38;5;241m|\u001b[39m \u001b[38;5;28mlist\u001b[39m[\u001b[38;5;28mint\u001b[39m] \u001b[38;5;241m|\u001b[39m \u001b[38;5;28mlist\u001b[39m[\u001b[38;5;28mstr\u001b[39m] \u001b[38;5;241m|\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m,\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m   1445\u001b[0m     \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwds,\n\u001b[1;32m   1446\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m DataFrame \u001b[38;5;241m|\u001b[39m \u001b[38;5;28mdict\u001b[39m[\u001b[38;5;28mstr\u001b[39m, DataFrame] \u001b[38;5;241m|\u001b[39m \u001b[38;5;28mdict\u001b[39m[\u001b[38;5;28mint\u001b[39m, DataFrame]:\n\u001b[1;32m   1447\u001b[0m     \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m   1448\u001b[0m \u001b[38;5;124;03m    Parse specified sheet(s) into a DataFrame.\u001b[39;00m\n\u001b[1;32m   1449\u001b[0m \n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m   1456\u001b[0m \u001b[38;5;124;03m        DataFrame from the passed in Excel file.\u001b[39;00m\n\u001b[1;32m   1457\u001b[0m \u001b[38;5;124;03m    \"\"\"\u001b[39;00m\n\u001b[0;32m-> 1458\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_reader\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparse\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m   1459\u001b[0m \u001b[43m        \u001b[49m\u001b[43msheet_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msheet_name\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1460\u001b[0m \u001b[43m        \u001b[49m\u001b[43mheader\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mheader\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1461\u001b[0m \u001b[43m        \u001b[49m\u001b[43mnames\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnames\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1462\u001b[0m \u001b[43m        \u001b[49m\u001b[43mindex_col\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindex_col\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1463\u001b[0m \u001b[43m        \u001b[49m\u001b[43musecols\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43musecols\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1464\u001b[0m \u001b[43m        \u001b[49m\u001b[43msqueeze\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msqueeze\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1465\u001b[0m \u001b[43m        \u001b[49m\u001b[43mconverters\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconverters\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1466\u001b[0m \u001b[43m        \u001b[49m\u001b[43mtrue_values\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtrue_values\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1467\u001b[0m \u001b[43m        \u001b[49m\u001b[43mfalse_values\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfalse_values\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1468\u001b[0m \u001b[43m        \u001b[49m\u001b[43mskiprows\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mskiprows\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1469\u001b[0m \u001b[43m        \u001b[49m\u001b[43mnrows\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnrows\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1470\u001b[0m \u001b[43m        \u001b[49m\u001b[43mna_values\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mna_values\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1471\u001b[0m \u001b[43m        \u001b[49m\u001b[43mparse_dates\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparse_dates\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1472\u001b[0m \u001b[43m        \u001b[49m\u001b[43mdate_parser\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdate_parser\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1473\u001b[0m \u001b[43m        \u001b[49m\u001b[43mthousands\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mthousands\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1474\u001b[0m \u001b[43m        \u001b[49m\u001b[43mcomment\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcomment\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1475\u001b[0m \u001b[43m        \u001b[49m\u001b[43mskipfooter\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mskipfooter\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1476\u001b[0m \u001b[43m        \u001b[49m\u001b[43mconvert_float\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconvert_float\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1477\u001b[0m \u001b[43m        \u001b[49m\u001b[43mmangle_dupe_cols\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmangle_dupe_cols\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1478\u001b[0m \u001b[43m        \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1479\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/io/excel/_base.py:634\u001b[0m, in \u001b[0;36mBaseExcelReader.parse\u001b[0;34m(self, sheet_name, header, names, index_col, usecols, squeeze, dtype, true_values, false_values, skiprows, nrows, na_values, verbose, parse_dates, date_parser, thousands, decimal, comment, skipfooter, convert_float, mangle_dupe_cols, **kwds)\u001b[0m\n\u001b[1;32m    631\u001b[0m     \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mReading sheet \u001b[39m\u001b[38;5;132;01m{\u001b[39;00masheetname\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m    633\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(asheetname, \u001b[38;5;28mstr\u001b[39m):\n\u001b[0;32m--> 634\u001b[0m     sheet \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_sheet_by_name\u001b[49m\u001b[43m(\u001b[49m\u001b[43masheetname\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    635\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:  \u001b[38;5;66;03m# assume an integer if not a string\u001b[39;00m\n\u001b[1;32m    636\u001b[0m     sheet \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mget_sheet_by_index(asheetname)\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/io/excel/_openpyxl.py:545\u001b[0m, in \u001b[0;36mOpenpyxlReader.get_sheet_by_name\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m    544\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mget_sheet_by_name\u001b[39m(\u001b[38;5;28mself\u001b[39m, name: \u001b[38;5;28mstr\u001b[39m):\n\u001b[0;32m--> 545\u001b[0m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_if_bad_sheet_by_name\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    546\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbook[name]\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/io/excel/_base.py:570\u001b[0m, in \u001b[0;36mBaseExcelReader.raise_if_bad_sheet_by_name\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m    568\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mraise_if_bad_sheet_by_name\u001b[39m(\u001b[38;5;28mself\u001b[39m, name: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m    569\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msheet_names:\n\u001b[0;32m--> 570\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWorksheet named \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mname\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m not found\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
      "\u001b[0;31mValueError\u001b[0m: Worksheet named 'salary' not found"
     ]
    }
   ],
   "source": [
    "# 读取 Excel表格 -- error: salary表格被覆盖了\n",
    "pd.read_excel('./data/salary.xlsx',\n",
    "              sheet_name='salary', # 读取哪一个工作表，默认第一个\n",
    "              header = 0, # 使用第一行数据作为列索引\n",
    "              names = list('ABCDE'), # 替换列索引\n",
    "              index_col = 3) # 指定行索引，B作为行索引"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "76e7a455",
   "metadata": {},
   "source": [
    "向一个文件中存入多个表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "284c3c92",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>IT</th>\n",
       "      <th>化工</th>\n",
       "      <th>生物</th>\n",
       "      <th>教师</th>\n",
       "      <th>士兵</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>26</td>\n",
       "      <td>45</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>39</td>\n",
       "      <td>38</td>\n",
       "      <td>30</td>\n",
       "      <td>46</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>40</td>\n",
       "      <td>14</td>\n",
       "      <td>23</td>\n",
       "      <td>17</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>29</td>\n",
       "      <td>21</td>\n",
       "      <td>4</td>\n",
       "      <td>16</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>11</td>\n",
       "      <td>15</td>\n",
       "      <td>43</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>26</td>\n",
       "      <td>1</td>\n",
       "      <td>31</td>\n",
       "      <td>12</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>28</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>43</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>41</td>\n",
       "      <td>12</td>\n",
       "      <td>30</td>\n",
       "      <td>33</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>18</td>\n",
       "      <td>5</td>\n",
       "      <td>29</td>\n",
       "      <td>16</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>36</td>\n",
       "      <td>23</td>\n",
       "      <td>40</td>\n",
       "      <td>34</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>28</td>\n",
       "      <td>18</td>\n",
       "      <td>28</td>\n",
       "      <td>4</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>11</td>\n",
       "      <td>8</td>\n",
       "      <td>30</td>\n",
       "      <td>31</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>33</td>\n",
       "      <td>48</td>\n",
       "      <td>31</td>\n",
       "      <td>22</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>31</td>\n",
       "      <td>25</td>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>45</td>\n",
       "      <td>43</td>\n",
       "      <td>32</td>\n",
       "      <td>19</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>9</td>\n",
       "      <td>34</td>\n",
       "      <td>29</td>\n",
       "      <td>31</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>21</td>\n",
       "      <td>47</td>\n",
       "      <td>32</td>\n",
       "      <td>42</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>4</td>\n",
       "      <td>24</td>\n",
       "      <td>15</td>\n",
       "      <td>32</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>33</td>\n",
       "      <td>34</td>\n",
       "      <td>30</td>\n",
       "      <td>21</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>46</td>\n",
       "      <td>19</td>\n",
       "      <td>44</td>\n",
       "      <td>48</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>45</td>\n",
       "      <td>2</td>\n",
       "      <td>41</td>\n",
       "      <td>10</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>28</td>\n",
       "      <td>49</td>\n",
       "      <td>9</td>\n",
       "      <td>20</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>36</td>\n",
       "      <td>45</td>\n",
       "      <td>45</td>\n",
       "      <td>49</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>16</td>\n",
       "      <td>31</td>\n",
       "      <td>39</td>\n",
       "      <td>17</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>38</td>\n",
       "      <td>42</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>42</td>\n",
       "      <td>49</td>\n",
       "      <td>33</td>\n",
       "      <td>40</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>33</td>\n",
       "      <td>26</td>\n",
       "      <td>10</td>\n",
       "      <td>13</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>45</td>\n",
       "      <td>41</td>\n",
       "      <td>42</td>\n",
       "      <td>46</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>5</td>\n",
       "      <td>13</td>\n",
       "      <td>33</td>\n",
       "      <td>44</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>6</td>\n",
       "      <td>26</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>30</td>\n",
       "      <td>22</td>\n",
       "      <td>18</td>\n",
       "      <td>3</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "      <td>20</td>\n",
       "      <td>24</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>0</td>\n",
       "      <td>15</td>\n",
       "      <td>17</td>\n",
       "      <td>46</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>20</td>\n",
       "      <td>30</td>\n",
       "      <td>15</td>\n",
       "      <td>12</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>3</td>\n",
       "      <td>44</td>\n",
       "      <td>22</td>\n",
       "      <td>49</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>14</td>\n",
       "      <td>42</td>\n",
       "      <td>15</td>\n",
       "      <td>32</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>20</td>\n",
       "      <td>23</td>\n",
       "      <td>16</td>\n",
       "      <td>28</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>16</td>\n",
       "      <td>40</td>\n",
       "      <td>39</td>\n",
       "      <td>33</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>15</td>\n",
       "      <td>32</td>\n",
       "      <td>33</td>\n",
       "      <td>5</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "      <td>45</td>\n",
       "      <td>23</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>29</td>\n",
       "      <td>30</td>\n",
       "      <td>23</td>\n",
       "      <td>6</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>20</td>\n",
       "      <td>10</td>\n",
       "      <td>5</td>\n",
       "      <td>22</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>24</td>\n",
       "      <td>38</td>\n",
       "      <td>3</td>\n",
       "      <td>48</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>16</td>\n",
       "      <td>3</td>\n",
       "      <td>12</td>\n",
       "      <td>34</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>43</td>\n",
       "      <td>19</td>\n",
       "      <td>16</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>11</td>\n",
       "      <td>21</td>\n",
       "      <td>30</td>\n",
       "      <td>25</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>45</td>\n",
       "      <td>14</td>\n",
       "      <td>12</td>\n",
       "      <td>48</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>36</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>5</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>15</td>\n",
       "      <td>37</td>\n",
       "      <td>15</td>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>33</td>\n",
       "      <td>41</td>\n",
       "      <td>11</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    IT  化工  生物  教师  士兵\n",
       "0   26  45   0   5   2\n",
       "1   39  38  30  46  43\n",
       "2   40  14  23  17  40\n",
       "3   29  21   4  16   5\n",
       "4   11  15  43   0   5\n",
       "5   26   1  31  12  11\n",
       "6   28   2   4  43  34\n",
       "7   41  12  30  33  42\n",
       "8   18   5  29  16  24\n",
       "9   36  23  40  34  31\n",
       "10  28  18  28   4  44\n",
       "11  11   8  30  31  49\n",
       "12  33  48  31  22  38\n",
       "13  31  25   9   5  46\n",
       "14  45  43  32  19  26\n",
       "15   9  34  29  31  22\n",
       "16  21  47  32  42  28\n",
       "17   4  24  15  32  10\n",
       "18  33  34  30  21  44\n",
       "19  46  19  44  48   5\n",
       "20  45   2  41  10  46\n",
       "21  28  49   9  20  29\n",
       "22  36  45  45  49  47\n",
       "23  16  31  39  17   0\n",
       "24  12  13  38  42  19\n",
       "25  42  49  33  40  27\n",
       "26  33  26  10  13   5\n",
       "27  45  41  42  46  49\n",
       "28   5  13  33  44  17\n",
       "29   6  26   3   8  25\n",
       "30  30  22  18   3  29\n",
       "31   1  22  20  24  36\n",
       "32   0  15  17  46  38\n",
       "33  20  30  15  12   1\n",
       "34   3  44  22  49  35\n",
       "35  14  42  15  32  30\n",
       "36  20  23  16  28  13\n",
       "37  16  40  39  33  39\n",
       "38  15  32  33   5  34\n",
       "39  10   3  45  23   8\n",
       "40  29  30  23   6  33\n",
       "41  20  10   5  22  39\n",
       "42  24  38   3  48  35\n",
       "43  16   3  12  34  44\n",
       "44  43  19  16   7   3\n",
       "45  11  21  30  25  17\n",
       "46  45  14  12  48  44\n",
       "47  36  14  14   5  19\n",
       "48  15  37  15  40  40\n",
       "49  33  41  11  41  33"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 一个Excel文件中保存多个工作表\n",
    "with pd.ExcelWriter('./data/data.xlsx') as writer:\n",
    "    df1.to_excel(writer, sheet_name='salary', index=False)\n",
    "    df2.to_excel(writer, sheet_name='score', index=False)\n",
    "\n",
    "# 第一个工作表 未被 第二个工作表覆盖\n",
    "pd.read_excel('./data/data.xlsx',sheet_name='salary')  # 读取Excel中指定名字的工作表"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36d9a733",
   "metadata": {},
   "source": [
    "## SQL\n",
    "![](2_Pandas数据分析库_images/1.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "8e356a73",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Python</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>27</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>11</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>35</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>44</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>33</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>39</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>26</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>31</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Tensorflow  Keras\n",
       "Python                   \n",
       "14              27     44\n",
       "20              11      4\n",
       "32              35     28\n",
       "7               44     47\n",
       "1                0     21\n",
       "17               2     22\n",
       "27              33     20\n",
       "18              39     38\n",
       "4               26     38\n",
       "6               31     29"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# SQLAlchemy是Python编程语言下的一款开源软件。提供了SQL工具包及对象关系映射（ORM）工具\n",
    "from sqlalchemy import create_engine\n",
    "\n",
    "# 创建 DataFrame数据\n",
    "df = pd.DataFrame(data=np.random.randint(0, 50, size=[150, 3]),  # 计算机科目的考试成绩\n",
    "                  columns=['Python', 'Tensorflow', 'Keras'])\n",
    "# 数据库连接\n",
    "conn = create_engine(\n",
    "    'mysql+pymysql://root:zxydsg123@localhost/pandas?charset=UTF8MB4')\n",
    "\n",
    "# 保存到数据库\n",
    "df.to_sql('score',  # 数据库中表名\n",
    "          conn, # 数据库连接\n",
    "          index=False, # 不保存索引\n",
    "          if_exists='append') # 如果表名存在，追加数据\n",
    "\n",
    "\n",
    "# 从数据库中加载\n",
    "pd.read_sql('select * from score limit 10', # sql查询语句\n",
    "            conn, # 数据库连接\n",
    "            index_col='Python') # 指定行索引名"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b8e149f",
   "metadata": {},
   "source": [
    "##  HDF5\n",
    "HDF5，可以存储不同类型数据的文件格式，后缀通常是.h5，它的结构是层次性的。\n",
    "\n",
    "一个HDF5文件可以被看作是一个组包含了各类不同的数据集。\n",
    "\n",
    "\n",
    "![](2_Pandas数据分析库_images/2.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ed9e2b4e",
   "metadata": {},
   "source": [
    "对于HDF5文件中的数据存储，有两个核心概念：**group 和 dataset**\n",
    "\n",
    "**目录就是HDF5中的group**, 描述了数据集dataset的分类信息，通过group 有效的将多种dataset 进行管理和区分；\n",
    "\n",
    "**文件就是HDF5中的dataset**, 表示的是具体的数据。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "c16270ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>IT</th>\n",
       "      <th>化工</th>\n",
       "      <th>生物</th>\n",
       "      <th>教师</th>\n",
       "      <th>士兵</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>42</td>\n",
       "      <td>28</td>\n",
       "      <td>27</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>30</td>\n",
       "      <td>27</td>\n",
       "      <td>29</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>19</td>\n",
       "      <td>19</td>\n",
       "      <td>19</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>17</td>\n",
       "      <td>28</td>\n",
       "      <td>13</td>\n",
       "      <td>0</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "      <td>44</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>43</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>28</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>16</td>\n",
       "      <td>19</td>\n",
       "      <td>48</td>\n",
       "      <td>17</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>29</td>\n",
       "      <td>11</td>\n",
       "      <td>17</td>\n",
       "      <td>49</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>34</td>\n",
       "      <td>34</td>\n",
       "      <td>26</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>47</td>\n",
       "      <td>31</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>30</td>\n",
       "      <td>30</td>\n",
       "      <td>47</td>\n",
       "      <td>28</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>43</td>\n",
       "      <td>0</td>\n",
       "      <td>36</td>\n",
       "      <td>48</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>22</td>\n",
       "      <td>2</td>\n",
       "      <td>33</td>\n",
       "      <td>31</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>42</td>\n",
       "      <td>5</td>\n",
       "      <td>30</td>\n",
       "      <td>4</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>45</td>\n",
       "      <td>16</td>\n",
       "      <td>24</td>\n",
       "      <td>31</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>12</td>\n",
       "      <td>15</td>\n",
       "      <td>27</td>\n",
       "      <td>1</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>22</td>\n",
       "      <td>34</td>\n",
       "      <td>31</td>\n",
       "      <td>6</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>44</td>\n",
       "      <td>4</td>\n",
       "      <td>45</td>\n",
       "      <td>11</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>41</td>\n",
       "      <td>49</td>\n",
       "      <td>1</td>\n",
       "      <td>13</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>48</td>\n",
       "      <td>39</td>\n",
       "      <td>42</td>\n",
       "      <td>31</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>30</td>\n",
       "      <td>0</td>\n",
       "      <td>37</td>\n",
       "      <td>21</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>15</td>\n",
       "      <td>24</td>\n",
       "      <td>24</td>\n",
       "      <td>29</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>9</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>41</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>16</td>\n",
       "      <td>33</td>\n",
       "      <td>27</td>\n",
       "      <td>29</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>3</td>\n",
       "      <td>38</td>\n",
       "      <td>24</td>\n",
       "      <td>4</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>46</td>\n",
       "      <td>29</td>\n",
       "      <td>30</td>\n",
       "      <td>29</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>33</td>\n",
       "      <td>16</td>\n",
       "      <td>41</td>\n",
       "      <td>1</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>14</td>\n",
       "      <td>32</td>\n",
       "      <td>22</td>\n",
       "      <td>29</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>29</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>1</td>\n",
       "      <td>11</td>\n",
       "      <td>3</td>\n",
       "      <td>46</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>20</td>\n",
       "      <td>24</td>\n",
       "      <td>27</td>\n",
       "      <td>30</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>32</td>\n",
       "      <td>14</td>\n",
       "      <td>12</td>\n",
       "      <td>3</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>46</td>\n",
       "      <td>22</td>\n",
       "      <td>45</td>\n",
       "      <td>16</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>45</td>\n",
       "      <td>49</td>\n",
       "      <td>45</td>\n",
       "      <td>8</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>32</td>\n",
       "      <td>9</td>\n",
       "      <td>30</td>\n",
       "      <td>2</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>43</td>\n",
       "      <td>22</td>\n",
       "      <td>34</td>\n",
       "      <td>26</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>4</td>\n",
       "      <td>46</td>\n",
       "      <td>1</td>\n",
       "      <td>21</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>26</td>\n",
       "      <td>4</td>\n",
       "      <td>36</td>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>6</td>\n",
       "      <td>46</td>\n",
       "      <td>45</td>\n",
       "      <td>32</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>20</td>\n",
       "      <td>20</td>\n",
       "      <td>30</td>\n",
       "      <td>39</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>25</td>\n",
       "      <td>17</td>\n",
       "      <td>21</td>\n",
       "      <td>18</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>29</td>\n",
       "      <td>25</td>\n",
       "      <td>2</td>\n",
       "      <td>32</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>1</td>\n",
       "      <td>20</td>\n",
       "      <td>38</td>\n",
       "      <td>0</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>49</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "      <td>45</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>6</td>\n",
       "      <td>31</td>\n",
       "      <td>22</td>\n",
       "      <td>28</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>17</td>\n",
       "      <td>39</td>\n",
       "      <td>44</td>\n",
       "      <td>11</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>7</td>\n",
       "      <td>33</td>\n",
       "      <td>33</td>\n",
       "      <td>39</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>42</td>\n",
       "      <td>43</td>\n",
       "      <td>15</td>\n",
       "      <td>42</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>37</td>\n",
       "      <td>45</td>\n",
       "      <td>0</td>\n",
       "      <td>42</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>41</td>\n",
       "      <td>40</td>\n",
       "      <td>30</td>\n",
       "      <td>1</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    IT  化工  生物  教师  士兵\n",
       "0   19  42  28  27  43\n",
       "1    1  30  27  29  40\n",
       "2   19  19  19   3   8\n",
       "3   17  28  13   0  18\n",
       "4    0   8   3  44  13\n",
       "5   43  11  29  28  26\n",
       "6   16  19  48  17  18\n",
       "7   29  11  17  49   4\n",
       "8   34  34  26   8   5\n",
       "9   47  31   2   8  10\n",
       "10  30  30  47  28   6\n",
       "11  43   0  36  48   2\n",
       "12  22   2  33  31   9\n",
       "13  42   5  30   4  16\n",
       "14  45  16  24  31  32\n",
       "15  12  15  27   1  14\n",
       "16  22  34  31   6  33\n",
       "17  44   4  45  11  10\n",
       "18  41  49   1  13  18\n",
       "19  48  39  42  31   5\n",
       "20  30   0  37  21  34\n",
       "21  15  24  24  29  12\n",
       "22   9   1   3  41  25\n",
       "23  16  33  27  29  32\n",
       "24   3  38  24   4  33\n",
       "25  46  29  30  29   0\n",
       "26  33  16  41   1  23\n",
       "27  14  32  22  29  13\n",
       "28   4   3  29   7   8\n",
       "29   1  11   3  46  42\n",
       "30  20  24  27  30  11\n",
       "31  32  14  12   3  23\n",
       "32  46  22  45  16  26\n",
       "33  45  49  45   8  13\n",
       "34  32   9  30   2  24\n",
       "35  43  22  34  26  10\n",
       "36   4  46   1  21  14\n",
       "37  26   4  36  21   7\n",
       "38   6  46  45  32   0\n",
       "39  20  20  30  39  48\n",
       "40  25  17  21  18  16\n",
       "41  29  25   2  32  15\n",
       "42   1  20  38   0  49\n",
       "43  49   2   8  45  24\n",
       "44   6  31  22  28  45\n",
       "45  17  39  44  11  49\n",
       "46   7  33  33  39  33\n",
       "47  42  43  15  42   6\n",
       "48  37  45   0  42   6\n",
       "49  41  40  30   1  45"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 = pd.DataFrame(data=np.random.randint(0, 50, size=[50, 5]),  # 薪资情况\n",
    "                   columns=['IT', '化工', '生物', '教师', '士兵'])\n",
    "\n",
    "df2 = pd.DataFrame(data=np.random.randint(0, 50, size=[150, 3]),  # 计算机科目的考试 成绩\n",
    "                   columns=['Python', 'Tensorflow', 'Keras'])  \n",
    "\n",
    "# 保存到当前路径下，文件命名是：data.h5\n",
    "df1.to_hdf('./data/data.h5', key='salary')  # 保存数据的 标记key\n",
    "\n",
    "df2.to_hdf('./data/data.h5', key='score')\n",
    "\n",
    "pd.read_hdf('./data/data.h5', key='salary')  # 获取指定标记的 数据"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "62449e5c",
   "metadata": {},
   "source": [
    "## 中文乱码问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "id": "6e3fbf45",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "id": "be03d02a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 保存时，指定了中文编码\n",
    "df.to_excel('./data/分数汇总2.xlsx',encoding='gbk')\n",
    "\n",
    "df.to_excel('./data/分数汇总3.xlsx',encoding='utf8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "id": "594535bf",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_csv('./data/分数汇总.csv',encoding='utf-8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "id": "027aa710",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>Python</th>\n",
       "      <th>Python等级</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>31</td>\n",
       "      <td>不及格</td>\n",
       "      <td>1</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>71</td>\n",
       "      <td>中等</td>\n",
       "      <td>69</td>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>92</td>\n",
       "      <td>优秀</td>\n",
       "      <td>24</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>52</td>\n",
       "      <td>不及格</td>\n",
       "      <td>16</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>85</td>\n",
       "      <td>优秀</td>\n",
       "      <td>95</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0  Python Python等级  Math  En\n",
       "0           0      31      不及格     1  44\n",
       "1           1      71       中等    69  67\n",
       "2           2      92       优秀    24  31\n",
       "3           3      52      不及格    16  56\n",
       "4           4      85       优秀    95  48"
      ]
     },
     "execution_count": 133,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_excel('./data/分数汇总3.xlsx')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "df904dda",
   "metadata": {},
   "source": [
    "# 数据选择"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8aec903e",
   "metadata": {},
   "source": [
    "## 字段数据 df[ ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "aa01d399",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>En</th>\n",
       "      <th>Math</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>75</td>\n",
       "      <td>110</td>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>21</td>\n",
       "      <td>95</td>\n",
       "      <td>104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>23</td>\n",
       "      <td>34</td>\n",
       "      <td>83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>128</td>\n",
       "      <td>13</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>92</td>\n",
       "      <td>49</td>\n",
       "      <td>104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>995</th>\n",
       "      <td>51</td>\n",
       "      <td>63</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>996</th>\n",
       "      <td>68</td>\n",
       "      <td>47</td>\n",
       "      <td>54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>997</th>\n",
       "      <td>96</td>\n",
       "      <td>22</td>\n",
       "      <td>147</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>998</th>\n",
       "      <td>30</td>\n",
       "      <td>98</td>\n",
       "      <td>64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>999</th>\n",
       "      <td>145</td>\n",
       "      <td>54</td>\n",
       "      <td>71</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1000 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Python   En  Math\n",
       "0        75  110    88\n",
       "1        21   95   104\n",
       "2        23   34    83\n",
       "3       128   13     0\n",
       "4        92   49   104\n",
       "..      ...  ...   ...\n",
       "995      51   63    46\n",
       "996      68   47    54\n",
       "997      96   22   147\n",
       "998      30   98    64\n",
       "999     145   54    71\n",
       "\n",
       "[1000 rows x 3 columns]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建 DataFrame:随机生成 1000*3 的整数\n",
    "df = pd.DataFrame(np.random.randint(0, 150, size=(1000, 3)),\n",
    "                  columns=['Python', 'En', 'Math'])\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "efe6479e",
   "metadata": {},
   "source": [
    "**列获取:**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "c524ee93",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0       75\n",
      "1       21\n",
      "2       23\n",
      "3      128\n",
      "4       92\n",
      "      ... \n",
      "995     51\n",
      "996     68\n",
      "997     96\n",
      "998     30\n",
      "999    145\n",
      "Name: Python, Length: 1000, dtype: int64\n",
      "------------------------------------\n",
      "0       75\n",
      "1       21\n",
      "2       23\n",
      "3      128\n",
      "4       92\n",
      "      ... \n",
      "995     51\n",
      "996     68\n",
      "997     96\n",
      "998     30\n",
      "999    145\n",
      "Name: Python, Length: 1000, dtype: int64\n",
      "------------------------------------\n"
     ]
    }
   ],
   "source": [
    "# Series，获取单列\n",
    "print(df['Python'])  \n",
    "print('------------------------------------')\n",
    "print(df.Python)\n",
    "print('------------------------------------')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "f74685d7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "     Python  Math\n",
      "0        75    88\n",
      "1        21   104\n",
      "2        23    83\n",
      "3       128     0\n",
      "4        92   104\n",
      "..      ...   ...\n",
      "995      51    46\n",
      "996      68    54\n",
      "997      96   147\n",
      "998      30    64\n",
      "999     145    71\n",
      "\n",
      "[1000 rows x 2 columns]\n",
      "------------------------------------\n",
      "      En\n",
      "0    110\n",
      "1     95\n",
      "2     34\n",
      "3     13\n",
      "4     49\n",
      "..   ...\n",
      "995   63\n",
      "996   47\n",
      "997   22\n",
      "998   98\n",
      "999   54\n",
      "\n",
      "[1000 rows x 1 columns]\n",
      "------------------------------------\n"
     ]
    }
   ],
   "source": [
    "# DataFrame，获取多列\n",
    "print(df[['Python', 'Math']]) \n",
    "print('------------------------------------')\n",
    "\n",
    "print(df[['En']]) # 类型为DataFrame\n",
    "print('------------------------------------')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cfd16636",
   "metadata": {},
   "source": [
    "**行获取:**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "2ae9ba46",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>38</td>\n",
       "      <td>72</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>40</td>\n",
       "      <td>17</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>98</td>\n",
       "      <td>58</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>57</td>\n",
       "      <td>148</td>\n",
       "      <td>127</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Math   En\n",
       "A      38    72   89\n",
       "B      40    17   38\n",
       "C      21     0   65\n",
       "D      98    58   23\n",
       "E      57   148  127"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = pd.DataFrame(np.random.randint(0, 150, size=(5, 3)),\n",
    "                   index=list('ABCDE'),\n",
    "                   columns=['Python', 'Math', 'En'])\n",
    "\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "d75b0291",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>En</th>\n",
       "      <th>Math</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>75</td>\n",
       "      <td>110</td>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>21</td>\n",
       "      <td>95</td>\n",
       "      <td>104</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python   En  Math\n",
       "0      75  110    88\n",
       "1      21   95   104"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[0:2] # 行切片"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "56c1a55a",
   "metadata": {},
   "source": [
    "## 标签选择 df.loc\n",
    "利用 行标签名、列标签名 进行数据筛选 -- df.loc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "f43f2e40",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>38</td>\n",
       "      <td>72</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>40</td>\n",
       "      <td>17</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>98</td>\n",
       "      <td>58</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>57</td>\n",
       "      <td>148</td>\n",
       "      <td>127</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Math   En\n",
       "A      38    72   89\n",
       "B      40    17   38\n",
       "C      21     0   65\n",
       "D      98    58   23\n",
       "E      57   148  127"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "476fbe8d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Python    38\n",
       "Math      72\n",
       "En        89\n",
       "Name: A, dtype: int64"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 行索引，指定 A -- 获取 A行\n",
    "df2.loc['A'] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "98058f84",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>38</td>\n",
       "      <td>72</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>98</td>\n",
       "      <td>58</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Math  En\n",
       "A      38    72  89\n",
       "D      98    58  23"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 行索引，指定 A、D -- 获取 A行、D行\n",
    "df2.loc[['A','D']] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "1af36c76",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>113</td>\n",
       "      <td>113</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>17</td>\n",
       "      <td>83</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>131</td>\n",
       "      <td>11</td>\n",
       "      <td>145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>51</td>\n",
       "      <td>58</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A     113         113     44\n",
       "C      17          83     65\n",
       "D     131          11    145\n",
       "F      51          58     65"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建数据 DataFrame\n",
    "df = pd.DataFrame(data=np.random.randint(0, 150, size=[10, 3]),  # 计算机科目的考试成绩\n",
    "                  index=list('ABCDEFGHIJ'),  # 行标签\n",
    "                  columns=['Python', 'Tensorflow', 'Keras']) # 列标签\n",
    "\n",
    "# 选取指定行标签数据\n",
    "df.loc[['A', 'C', 'D', 'F']]  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "accb9ecc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>113</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>74</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>17</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>131</td>\n",
       "      <td>145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>90</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras\n",
       "A     113     44\n",
       "B      74     43\n",
       "C      17     65\n",
       "D     131    145\n",
       "E      90     13"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc['A':'E', ['Python', 'Keras']]  # 根据行标签切片，选取指定列标签的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "876f7259",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Keras</th>\n",
       "      <th>Tensorflow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>44</td>\n",
       "      <td>113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>43</td>\n",
       "      <td>144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>65</td>\n",
       "      <td>83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>145</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>13</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>65</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>81</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>21</td>\n",
       "      <td>71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>9</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>75</td>\n",
       "      <td>63</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Keras  Tensorflow\n",
       "A     44         113\n",
       "B     43         144\n",
       "C     65          83\n",
       "D    145          11\n",
       "E     13          25\n",
       "F     65          58\n",
       "G     81          90\n",
       "H     21          71\n",
       "I      9          23\n",
       "J     75          63"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[:, ['Keras', 'Tensorflow']]  # :默认保留所有行，指定获取特定列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "963c3d80",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>90</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>72</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>87</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow\n",
       "E      90          25\n",
       "G      72          90\n",
       "I      87          23"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc['E'::2, 'Python':'Tensorflow']  # 行切片从标签E开始每2个中取一个，列标签进行切片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "155fc48d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "113"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc['A', 'Python']  # 选取标量值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1638fd26",
   "metadata": {},
   "source": [
    "## 位置选择 df.iloc\n",
    "利用 行索引、列索引 进行筛选 -- df.iloc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "a0aa0ff4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>38</td>\n",
       "      <td>72</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>40</td>\n",
       "      <td>17</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>98</td>\n",
       "      <td>58</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>57</td>\n",
       "      <td>148</td>\n",
       "      <td>127</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Math   En\n",
       "A      38    72   89\n",
       "B      40    17   38\n",
       "C      21     0   65\n",
       "D      98    58   23\n",
       "E      57   148  127"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "d4d1c9cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Python    38\n",
       "Math      72\n",
       "En        89\n",
       "Name: A, dtype: int64"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取 第1行\n",
    "df2.iloc[0] # 自然数索引 0 ~ n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "b2afbc74",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>38</td>\n",
       "      <td>72</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>98</td>\n",
       "      <td>58</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Math  En\n",
       "A      38    72  89\n",
       "D      98    58  23"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 选取指定行\n",
    "df2.iloc[[0, 3]] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "ec670cdb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>14</td>\n",
       "      <td>21</td>\n",
       "      <td>124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>145</td>\n",
       "      <td>28</td>\n",
       "      <td>143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>79</td>\n",
       "      <td>21</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>14</td>\n",
       "      <td>48</td>\n",
       "      <td>72</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>148</td>\n",
       "      <td>32</td>\n",
       "      <td>126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>69</td>\n",
       "      <td>93</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>149</td>\n",
       "      <td>114</td>\n",
       "      <td>144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>108</td>\n",
       "      <td>122</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>21</td>\n",
       "      <td>149</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>59</td>\n",
       "      <td>40</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A      14          21    124\n",
       "B     145          28    143\n",
       "C      79          21     90\n",
       "D      14          48     72\n",
       "E     148          32    126\n",
       "F      69          93     41\n",
       "G     149         114    144\n",
       "H     108         122    100\n",
       "I      21         149     48\n",
       "J      59          40     22"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame(data=np.random.randint(0, 150, size=[10, 3]),  # 计算机科目的考试成绩\n",
    "                  index=list('ABCDEFGHIJ'),  # 行标签\n",
    "                  columns=['Python', 'Tensorflow', 'Keras']) # 列标签\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "5f26e718",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Python        148\n",
       "Tensorflow     32\n",
       "Keras         126\n",
       "Name: E, dtype: int64"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[4]  # 用整数位置选择特定行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "ccc9209c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>79</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>14</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>148</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>69</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>149</td>\n",
       "      <td>114</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>108</td>\n",
       "      <td>122</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow\n",
       "C      79          21\n",
       "D      14          48\n",
       "E     148          32\n",
       "F      69          93\n",
       "G     149         114\n",
       "H     108         122"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[2:8, 0:2]  # 用整数切片 -- 选取特定 行和列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "82558e95",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Tensorflow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>145</td>\n",
       "      <td>143</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>14</td>\n",
       "      <td>72</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>69</td>\n",
       "      <td>41</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Tensorflow\n",
       "B     145    143          28\n",
       "D      14     72          48\n",
       "F      69     41          93"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[[1, 3, 5], [0, 2, 1]]  # 整数列表，选取指定位置 -- 选取特定 行和列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "12fc5182",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>145</td>\n",
       "      <td>28</td>\n",
       "      <td>143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>79</td>\n",
       "      <td>21</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "B     145          28    143\n",
       "C      79          21     90"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[1:3, :]  # 行切片，保留所有列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "037f4021",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>14</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>145</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>79</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>14</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>148</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>69</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>149</td>\n",
       "      <td>114</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>108</td>\n",
       "      <td>122</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>21</td>\n",
       "      <td>149</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>59</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow\n",
       "A      14          21\n",
       "B     145          28\n",
       "C      79          21\n",
       "D      14          48\n",
       "E     148          32\n",
       "F      69          93\n",
       "G     149         114\n",
       "H     108         122\n",
       "I      21         149\n",
       "J      59          40"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[:, :2]  # 列切片，保留所有行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "72b032b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>14</td>\n",
       "      <td>21</td>\n",
       "      <td>124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>145</td>\n",
       "      <td>28</td>\n",
       "      <td>143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>79</td>\n",
       "      <td>21</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>14</td>\n",
       "      <td>48</td>\n",
       "      <td>72</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>148</td>\n",
       "      <td>32</td>\n",
       "      <td>126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>69</td>\n",
       "      <td>93</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>149</td>\n",
       "      <td>114</td>\n",
       "      <td>144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>108</td>\n",
       "      <td>122</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>21</td>\n",
       "      <td>149</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>59</td>\n",
       "      <td>40</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A      14          21    124\n",
       "B     145          28    143\n",
       "C      79          21     90\n",
       "D      14          48     72\n",
       "E     148          32    126\n",
       "F      69          93     41\n",
       "G     149         114    144\n",
       "H     108         122    100\n",
       "I      21         149     48\n",
       "J      59          40     22"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "cc8a22b5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "124"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[0, 2]  # 选取标量值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7972ed6f",
   "metadata": {},
   "source": [
    "## 获取具体的数值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "f180ad91",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>38</td>\n",
       "      <td>72</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>40</td>\n",
       "      <td>17</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>98</td>\n",
       "      <td>58</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>57</td>\n",
       "      <td>148</td>\n",
       "      <td>127</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Math   En\n",
       "A      38    72   89\n",
       "B      40    17   38\n",
       "C      21     0   65\n",
       "D      98    58   23\n",
       "E      57   148  127"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "a71d21ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "17"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2['Math']['B'] # 分开写"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "63404078",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "17"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.loc['B']['Math']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "8d4725d0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "17"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# loc 表示，先获取行，再获取列\n",
    "df2.loc['B','Math']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "f886221d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "17"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# iloc 表示，先获取行，再获取列\n",
    "df2.iloc[1,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "c92bd90c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>72</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>17</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>0</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Math  En\n",
       "A    72  89\n",
       "B    17  38\n",
       "C     0  65"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.loc['A':'C','Math':]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "2b15f464",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>21</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>98</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  En\n",
       "C      21  65\n",
       "D      98  23"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.iloc[2:4,[0,-1]]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "48835080",
   "metadata": {},
   "source": [
    "## boolean索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "d7fdda61",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>14</td>\n",
       "      <td>21</td>\n",
       "      <td>124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>145</td>\n",
       "      <td>28</td>\n",
       "      <td>143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>79</td>\n",
       "      <td>21</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>14</td>\n",
       "      <td>48</td>\n",
       "      <td>72</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>148</td>\n",
       "      <td>32</td>\n",
       "      <td>126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>69</td>\n",
       "      <td>93</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>149</td>\n",
       "      <td>114</td>\n",
       "      <td>144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>108</td>\n",
       "      <td>122</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>21</td>\n",
       "      <td>149</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>59</td>\n",
       "      <td>40</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A      14          21    124\n",
       "B     145          28    143\n",
       "C      79          21     90\n",
       "D      14          48     72\n",
       "E     148          32    126\n",
       "F      69          93     41\n",
       "G     149         114    144\n",
       "H     108         122    100\n",
       "I      21         149     48\n",
       "J      59          40     22"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "ffb7cda5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A    False\n",
      "B     True\n",
      "C     True\n",
      "D    False\n",
      "E     True\n",
      "F     True\n",
      "G     True\n",
      "H     True\n",
      "I    False\n",
      "J     True\n",
      "Name: Python, dtype: bool\n",
      "-----------------------\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>145</td>\n",
       "      <td>28</td>\n",
       "      <td>143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>79</td>\n",
       "      <td>21</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>148</td>\n",
       "      <td>32</td>\n",
       "      <td>126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>69</td>\n",
       "      <td>93</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>149</td>\n",
       "      <td>114</td>\n",
       "      <td>144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>108</td>\n",
       "      <td>122</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>59</td>\n",
       "      <td>40</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "B     145          28    143\n",
       "C      79          21     90\n",
       "E     148          32    126\n",
       "F      69          93     41\n",
       "G     149         114    144\n",
       "H     108         122    100\n",
       "J      59          40     22"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取df中，满足 Python成绩 > 50 的行数据\n",
    "cond = df['Python'] > 50\n",
    "\n",
    "print(cond)\n",
    "print('-----------------------')\n",
    "\n",
    "df[cond]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "31ef9879",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>69</td>\n",
       "      <td>93</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>149</td>\n",
       "      <td>114</td>\n",
       "      <td>144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>108</td>\n",
       "      <td>122</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "F      69          93     41\n",
       "G     149         114    144\n",
       "H     108         122    100"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取df中，Python成绩大于50，Tensorflow成绩大于60 的行\n",
    "cond1 = df['Python'] > 50\n",
    "\n",
    "cond2 = df['Tensorflow'] > 60\n",
    "\n",
    "cond = cond1 & cond2\n",
    "\n",
    "df[cond]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "16edb965",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>14</td>\n",
       "      <td>21</td>\n",
       "      <td>124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>79</td>\n",
       "      <td>21</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>69</td>\n",
       "      <td>93</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A      14          21    124\n",
       "C      79          21     90\n",
       "F      69          93     41"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取指定的行\n",
    "# isin判断是否在数组中，返回也是boolean类型值\n",
    "df[df.index.isin(['A','C','F'])] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "8e89e508",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>38</td>\n",
       "      <td>72</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>40</td>\n",
       "      <td>17</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>98</td>\n",
       "      <td>58</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>57</td>\n",
       "      <td>148</td>\n",
       "      <td>127</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Math   En\n",
       "A      38    72   89\n",
       "B      40    17   38\n",
       "C      21     0   65\n",
       "D      98    58   23\n",
       "E      57   148  127"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "804af803",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A     72\n",
       "B     17\n",
       "C      0\n",
       "D     58\n",
       "E    148\n",
       "Name: Math, dtype: int64"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取某列数据\n",
    "df2['Math'] # 只能操作列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "38ab7b88",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'B'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py:3621\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m   3620\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 3621\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_engine\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcasted_key\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   3622\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/_libs/index.pyx:136\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/_libs/index.pyx:163\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5198\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5206\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
      "\u001b[0;31mKeyError\u001b[0m: 'B'",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "Input \u001b[0;32mIn [67]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mdf2\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mB\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/frame.py:3505\u001b[0m, in \u001b[0;36mDataFrame.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m   3503\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcolumns\u001b[38;5;241m.\u001b[39mnlevels \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[1;32m   3504\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_getitem_multilevel(key)\n\u001b[0;32m-> 3505\u001b[0m indexer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcolumns\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   3506\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m is_integer(indexer):\n\u001b[1;32m   3507\u001b[0m     indexer \u001b[38;5;241m=\u001b[39m [indexer]\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py:3623\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m   3621\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_engine\u001b[38;5;241m.\u001b[39mget_loc(casted_key)\n\u001b[1;32m   3622\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[0;32m-> 3623\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01merr\u001b[39;00m\n\u001b[1;32m   3624\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n\u001b[1;32m   3625\u001b[0m     \u001b[38;5;66;03m# If we have a listlike key, _check_indexing_error will raise\u001b[39;00m\n\u001b[1;32m   3626\u001b[0m     \u001b[38;5;66;03m#  InvalidIndexError. Otherwise we fall through and re-raise\u001b[39;00m\n\u001b[1;32m   3627\u001b[0m     \u001b[38;5;66;03m#  the TypeError.\u001b[39;00m\n\u001b[1;32m   3628\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_check_indexing_error(key)\n",
      "\u001b[0;31mKeyError\u001b[0m: 'B'"
     ]
    }
   ],
   "source": [
    "df2['B'] # error: B是行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "18454da7",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "('Math', 'B')",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py:3621\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m   3620\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 3621\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_engine\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcasted_key\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   3622\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/_libs/index.pyx:136\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/_libs/index.pyx:163\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5198\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5206\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
      "\u001b[0;31mKeyError\u001b[0m: ('Math', 'B')",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "Input \u001b[0;32mIn [68]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mdf2\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mMath\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mB\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/frame.py:3505\u001b[0m, in \u001b[0;36mDataFrame.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m   3503\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcolumns\u001b[38;5;241m.\u001b[39mnlevels \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[1;32m   3504\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_getitem_multilevel(key)\n\u001b[0;32m-> 3505\u001b[0m indexer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcolumns\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   3506\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m is_integer(indexer):\n\u001b[1;32m   3507\u001b[0m     indexer \u001b[38;5;241m=\u001b[39m [indexer]\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py:3623\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m   3621\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_engine\u001b[38;5;241m.\u001b[39mget_loc(casted_key)\n\u001b[1;32m   3622\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[0;32m-> 3623\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01merr\u001b[39;00m\n\u001b[1;32m   3624\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n\u001b[1;32m   3625\u001b[0m     \u001b[38;5;66;03m# If we have a listlike key, _check_indexing_error will raise\u001b[39;00m\n\u001b[1;32m   3626\u001b[0m     \u001b[38;5;66;03m#  InvalidIndexError. Otherwise we fall through and re-raise\u001b[39;00m\n\u001b[1;32m   3627\u001b[0m     \u001b[38;5;66;03m#  the TypeError.\u001b[39;00m\n\u001b[1;32m   3628\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_check_indexing_error(key)\n",
      "\u001b[0;31mKeyError\u001b[0m: ('Math', 'B')"
     ]
    }
   ],
   "source": [
    "df2['Math','B'] # error: 只能操作列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "d3fa7a9a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Tom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Lily</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Ana</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Jane</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Yang</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Joe</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   name\n",
       "1   Tom\n",
       "2  Jack\n",
       "3  Lily\n",
       "4   Ana\n",
       "5  Jane\n",
       "6  Yang\n",
       "7   Joe"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = {\n",
    "    'name': pd.Series(['Tom', 'Jack', 'Lily', 'Ana', 'Jane', 'Yang', 'Joe'], # name列的数值\n",
    "                          index=np.arange(1, 8)) # 行索引\n",
    "}\n",
    "\n",
    "# 获取指定行\n",
    "df = pd.DataFrame(data, index=[1, 2, 3, 4, 5, 6, 7])\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1fd100e4",
   "metadata": {},
   "source": [
    "# 赋值操作\n",
    "创建了20行3列的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "cd235ecb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>36</td>\n",
       "      <td>22</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>14</td>\n",
       "      <td>29</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>17</td>\n",
       "      <td>4</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>47</td>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>29</td>\n",
       "      <td>42</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>38</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>37</td>\n",
       "      <td>42</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2</td>\n",
       "      <td>12</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>49</td>\n",
       "      <td>25</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>47</td>\n",
       "      <td>48</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>34</td>\n",
       "      <td>31</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>41</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>5</td>\n",
       "      <td>28</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>11</td>\n",
       "      <td>7</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>45</td>\n",
       "      <td>17</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>36</td>\n",
       "      <td>18</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>33</td>\n",
       "      <td>12</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>34</td>\n",
       "      <td>40</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>10</td>\n",
       "      <td>8</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>21</td>\n",
       "      <td>18</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python  Math  En\n",
       "0       36    22  25\n",
       "1       14    29   1\n",
       "2       17     4  23\n",
       "3       47    21   7\n",
       "4       29    42  26\n",
       "5       38     9   2\n",
       "6       37    42  36\n",
       "7        2    12  45\n",
       "8       49    25  14\n",
       "9       47    48  40\n",
       "10      34    31   2\n",
       "11      41    10   3\n",
       "12       5    28  43\n",
       "13      11     7  22\n",
       "14      45    17   3\n",
       "15      36    18   4\n",
       "16      33    12  47\n",
       "17      34    40   4\n",
       "18      10     8  32\n",
       "19      21    18  34"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(np.random.randint(0,50,size = (20,3)), # 创建20行3列的数据\n",
    "                  columns=['Python','Math','En']) # 列标签\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "850a0378",
   "metadata": {},
   "source": [
    "增加一列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "b96d1a87",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "      <th>物理</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>36</td>\n",
       "      <td>22</td>\n",
       "      <td>25</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>14</td>\n",
       "      <td>29</td>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>17</td>\n",
       "      <td>4</td>\n",
       "      <td>23</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>47</td>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>29</td>\n",
       "      <td>42</td>\n",
       "      <td>26</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>38</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>37</td>\n",
       "      <td>42</td>\n",
       "      <td>36</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2</td>\n",
       "      <td>12</td>\n",
       "      <td>45</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>49</td>\n",
       "      <td>25</td>\n",
       "      <td>14</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>47</td>\n",
       "      <td>48</td>\n",
       "      <td>40</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>34</td>\n",
       "      <td>31</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>41</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>5</td>\n",
       "      <td>28</td>\n",
       "      <td>43</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>11</td>\n",
       "      <td>7</td>\n",
       "      <td>22</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>45</td>\n",
       "      <td>17</td>\n",
       "      <td>3</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>36</td>\n",
       "      <td>18</td>\n",
       "      <td>4</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>33</td>\n",
       "      <td>12</td>\n",
       "      <td>47</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>34</td>\n",
       "      <td>40</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>10</td>\n",
       "      <td>8</td>\n",
       "      <td>32</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>21</td>\n",
       "      <td>18</td>\n",
       "      <td>34</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python  Math  En  物理\n",
       "0       36    22  25  40\n",
       "1       14    29   1  22\n",
       "2       17     4  23   7\n",
       "3       47    21   7  31\n",
       "4       29    42  26  40\n",
       "5       38     9   2  10\n",
       "6       37    42  36  36\n",
       "7        2    12  45   6\n",
       "8       49    25  14  49\n",
       "9       47    48  40  18\n",
       "10      34    31   2   3\n",
       "11      41    10   3  49\n",
       "12       5    28  43  34\n",
       "13      11     7  22   8\n",
       "14      45    17   3  40\n",
       "15      36    18   4  34\n",
       "16      33    12  47  29\n",
       "17      34    40   4   5\n",
       "18      10     8  32  13\n",
       "19      21    18  34  37"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['物理'] = np.random.randint(0,50,size = 20 )\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "365eb461",
   "metadata": {},
   "source": [
    "将Python增加10分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "55a6d87a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "      <th>物理</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>46</td>\n",
       "      <td>22</td>\n",
       "      <td>25</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>24</td>\n",
       "      <td>29</td>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>27</td>\n",
       "      <td>4</td>\n",
       "      <td>23</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>57</td>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>39</td>\n",
       "      <td>42</td>\n",
       "      <td>26</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>48</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>47</td>\n",
       "      <td>42</td>\n",
       "      <td>36</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>45</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>59</td>\n",
       "      <td>25</td>\n",
       "      <td>14</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>57</td>\n",
       "      <td>48</td>\n",
       "      <td>40</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>44</td>\n",
       "      <td>31</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>51</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>15</td>\n",
       "      <td>28</td>\n",
       "      <td>43</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "      <td>22</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>55</td>\n",
       "      <td>17</td>\n",
       "      <td>3</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>46</td>\n",
       "      <td>18</td>\n",
       "      <td>4</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>43</td>\n",
       "      <td>12</td>\n",
       "      <td>47</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>44</td>\n",
       "      <td>40</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>20</td>\n",
       "      <td>8</td>\n",
       "      <td>32</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>31</td>\n",
       "      <td>18</td>\n",
       "      <td>34</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python  Math  En  物理\n",
       "0       46    22  25  40\n",
       "1       24    29   1  22\n",
       "2       27     4  23   7\n",
       "3       57    21   7  31\n",
       "4       39    42  26  40\n",
       "5       48     9   2  10\n",
       "6       47    42  36  36\n",
       "7       12    12  45   6\n",
       "8       59    25  14  49\n",
       "9       57    48  40  18\n",
       "10      44    31   2   3\n",
       "11      51    10   3  49\n",
       "12      15    28  43  34\n",
       "13      21     7  22   8\n",
       "14      55    17   3  40\n",
       "15      46    18   4  34\n",
       "16      43    12  47  29\n",
       "17      44    40   4   5\n",
       "18      20     8  32  13\n",
       "19      31    18  34  37"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Python'] += 10\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b6170d81",
   "metadata": {},
   "source": [
    "将Math、En，索引是2、3的人变成100分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "378a2a33",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/0q/2y7xgmvn00b1090yx3d_n1140000gn/T/ipykernel_58118/318881231.py:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  df[['Math','En']][[2,3]] = 100 # 修改成功\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "      <th>物理</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>46</td>\n",
       "      <td>22</td>\n",
       "      <td>25</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>24</td>\n",
       "      <td>29</td>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>27</td>\n",
       "      <td>4</td>\n",
       "      <td>23</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>57</td>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>39</td>\n",
       "      <td>42</td>\n",
       "      <td>26</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>48</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>47</td>\n",
       "      <td>42</td>\n",
       "      <td>36</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>45</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>59</td>\n",
       "      <td>25</td>\n",
       "      <td>14</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>57</td>\n",
       "      <td>48</td>\n",
       "      <td>40</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>44</td>\n",
       "      <td>31</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>51</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>15</td>\n",
       "      <td>28</td>\n",
       "      <td>43</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "      <td>22</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>55</td>\n",
       "      <td>17</td>\n",
       "      <td>3</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>46</td>\n",
       "      <td>18</td>\n",
       "      <td>4</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>43</td>\n",
       "      <td>12</td>\n",
       "      <td>47</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>44</td>\n",
       "      <td>40</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>20</td>\n",
       "      <td>8</td>\n",
       "      <td>32</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>31</td>\n",
       "      <td>18</td>\n",
       "      <td>34</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python  Math  En  物理\n",
       "0       46    22  25  40\n",
       "1       24    29   1  22\n",
       "2       27     4  23   7\n",
       "3       57    21   7  31\n",
       "4       39    42  26  40\n",
       "5       48     9   2  10\n",
       "6       47    42  36  36\n",
       "7       12    12  45   6\n",
       "8       59    25  14  49\n",
       "9       57    48  40  18\n",
       "10      44    31   2   3\n",
       "11      51    10   3  49\n",
       "12      15    28  43  34\n",
       "13      21     7  22   8\n",
       "14      55    17   3  40\n",
       "15      46    18   4  34\n",
       "16      43    12  47  29\n",
       "17      44    40   4   5\n",
       "18      20     8  32  13\n",
       "19      31    18  34  37"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[['Math','En']][[2,3]] = 100 # 修改成功\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "737954ac",
   "metadata": {},
   "source": [
    "批量修改多个数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "f59a9c52",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "      <th>物理</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>46</td>\n",
       "      <td>22</td>\n",
       "      <td>25</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>24</td>\n",
       "      <td>29</td>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1024</td>\n",
       "      <td>4</td>\n",
       "      <td>1024</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1024</td>\n",
       "      <td>21</td>\n",
       "      <td>1024</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>39</td>\n",
       "      <td>42</td>\n",
       "      <td>26</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>48</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>47</td>\n",
       "      <td>42</td>\n",
       "      <td>36</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>45</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>59</td>\n",
       "      <td>25</td>\n",
       "      <td>14</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>57</td>\n",
       "      <td>48</td>\n",
       "      <td>40</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>44</td>\n",
       "      <td>31</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>51</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>15</td>\n",
       "      <td>28</td>\n",
       "      <td>43</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "      <td>22</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>55</td>\n",
       "      <td>17</td>\n",
       "      <td>3</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>46</td>\n",
       "      <td>18</td>\n",
       "      <td>4</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>43</td>\n",
       "      <td>12</td>\n",
       "      <td>47</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>44</td>\n",
       "      <td>40</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>20</td>\n",
       "      <td>8</td>\n",
       "      <td>32</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>31</td>\n",
       "      <td>18</td>\n",
       "      <td>34</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python  Math    En  物理\n",
       "0       46    22    25  40\n",
       "1       24    29     1  22\n",
       "2     1024     4  1024   7\n",
       "3     1024    21  1024  31\n",
       "4       39    42    26  40\n",
       "5       48     9     2  10\n",
       "6       47    42    36  36\n",
       "7       12    12    45   6\n",
       "8       59    25    14  49\n",
       "9       57    48    40  18\n",
       "10      44    31     2   3\n",
       "11      51    10     3  49\n",
       "12      15    28    43  34\n",
       "13      21     7    22   8\n",
       "14      55    17     3  40\n",
       "15      46    18     4  34\n",
       "16      43    12    47  29\n",
       "17      44    40     4   5\n",
       "18      20     8    32  13\n",
       "19      31    18    34  37"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[[2,3],['Python','En']] = 1024\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "f84fe4e3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "      <th>物理</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>102400</td>\n",
       "      <td>400</td>\n",
       "      <td>102400</td>\n",
       "      <td>700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1200</td>\n",
       "      <td>1200</td>\n",
       "      <td>4500</td>\n",
       "      <td>600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>4400</td>\n",
       "      <td>3100</td>\n",
       "      <td>200</td>\n",
       "      <td>300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2100</td>\n",
       "      <td>700</td>\n",
       "      <td>2200</td>\n",
       "      <td>800</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>4400</td>\n",
       "      <td>4000</td>\n",
       "      <td>400</td>\n",
       "      <td>500</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python  Math      En   物理\n",
       "2   102400   400  102400  700\n",
       "7     1200  1200    4500  600\n",
       "10    4400  3100     200  300\n",
       "13    2100   700    2200  800\n",
       "17    4400  4000     400  500"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cond = df['物理'] < 10\n",
    "\n",
    "df[cond] * 100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "9dace6c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "      <th>物理</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1024</td>\n",
       "      <td>4</td>\n",
       "      <td>1024</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>45</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>44</td>\n",
       "      <td>31</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>21</td>\n",
       "      <td>7</td>\n",
       "      <td>22</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>44</td>\n",
       "      <td>40</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python  Math    En  物理\n",
       "2     1024     4  1024   7\n",
       "7       12    12    45   6\n",
       "10      44    31     2   3\n",
       "13      21     7    22   8\n",
       "17      44    40     4   5"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 原数据不变\n",
    "df[cond]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "26864b54",
   "metadata": {},
   "outputs": [],
   "source": [
    "# loc方式修改数据\n",
    "df.loc[cond] -= 100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "dec2e120",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "      <th>物理</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>924</td>\n",
       "      <td>-96</td>\n",
       "      <td>924</td>\n",
       "      <td>-93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-88</td>\n",
       "      <td>-88</td>\n",
       "      <td>-55</td>\n",
       "      <td>-94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>-56</td>\n",
       "      <td>-69</td>\n",
       "      <td>-98</td>\n",
       "      <td>-97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>-79</td>\n",
       "      <td>-93</td>\n",
       "      <td>-78</td>\n",
       "      <td>-92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>-56</td>\n",
       "      <td>-60</td>\n",
       "      <td>-96</td>\n",
       "      <td>-95</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python  Math   En  物理\n",
       "2      924   -96  924 -93\n",
       "7      -88   -88  -55 -94\n",
       "10     -56   -69  -98 -97\n",
       "13     -79   -93  -78 -92\n",
       "17     -56   -60  -96 -95"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 原数据发生了变化\n",
    "df[cond]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "06c908a4",
   "metadata": {},
   "source": [
    "# 数据集成\n",
    "pandas 提供了多种将 Series、DataFrame 对象组合在一起的功能"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "52a31ee6",
   "metadata": {},
   "source": [
    "## concat数据串联"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "5b293c94",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>63</td>\n",
       "      <td>136</td>\n",
       "      <td>116</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>133</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>35</td>\n",
       "      <td>57</td>\n",
       "      <td>82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>7</td>\n",
       "      <td>38</td>\n",
       "      <td>82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>89</td>\n",
       "      <td>111</td>\n",
       "      <td>101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>89</td>\n",
       "      <td>132</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>129</td>\n",
       "      <td>141</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>13</td>\n",
       "      <td>105</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>58</td>\n",
       "      <td>17</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>122</td>\n",
       "      <td>117</td>\n",
       "      <td>147</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A      63         136    116\n",
       "B     133           1      9\n",
       "C      35          57     82\n",
       "D       7          38     82\n",
       "E      89         111    101\n",
       "F      89         132     10\n",
       "G     129         141     93\n",
       "H      13         105     93\n",
       "I      58          17     23\n",
       "J     122         117    147"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>46</td>\n",
       "      <td>89</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>L</th>\n",
       "      <td>84</td>\n",
       "      <td>34</td>\n",
       "      <td>131</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>145</td>\n",
       "      <td>113</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>N</th>\n",
       "      <td>136</td>\n",
       "      <td>11</td>\n",
       "      <td>96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>O</th>\n",
       "      <td>94</td>\n",
       "      <td>8</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>P</th>\n",
       "      <td>25</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q</th>\n",
       "      <td>34</td>\n",
       "      <td>68</td>\n",
       "      <td>61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>R</th>\n",
       "      <td>36</td>\n",
       "      <td>40</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S</th>\n",
       "      <td>51</td>\n",
       "      <td>16</td>\n",
       "      <td>98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>87</td>\n",
       "      <td>30</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "K      46          89     93\n",
       "L      84          34    131\n",
       "M     145         113     39\n",
       "N     136          11     96\n",
       "O      94           8     34\n",
       "P      25          10      3\n",
       "Q      34          68     61\n",
       "R      36          40     27\n",
       "S      51          16     98\n",
       "T      87          30     89"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PyTorch</th>\n",
       "      <th>Paddle</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>59</td>\n",
       "      <td>103</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>127</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>87</td>\n",
       "      <td>95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>8</td>\n",
       "      <td>69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>142</td>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>85</td>\n",
       "      <td>63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>140</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>46</td>\n",
       "      <td>57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>39</td>\n",
       "      <td>146</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>73</td>\n",
       "      <td>133</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   PyTorch  Paddle\n",
       "A       59     103\n",
       "B      127      48\n",
       "C       87      95\n",
       "D        8      69\n",
       "E      142      88\n",
       "F       85      63\n",
       "G      140      49\n",
       "H       46      57\n",
       "I       39     146\n",
       "J       73     133"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "# df1 一班考试成绩\n",
    "df1 = pd.DataFrame(data = np.random.randint(0,150,size = [10,3]), # 随机生成 计算机科目的考试成绩\n",
    "                  index = list('ABCDEFGHIJ'), # 行标签，用户\n",
    "                  columns=['Python','Tensorflow','Keras']) # 考试科目\n",
    "\n",
    "# df2 二班考试科目\n",
    "df2 = pd.DataFrame(data = np.random.randint(0,150,size = [10,3]), # 随机生成 计算机科目的考试成绩\n",
    "                  index = list('KLMNOPQRST'), # 行标签，用户\n",
    "                  columns=['Python','Tensorflow','Keras']) # 考试科目\n",
    "\n",
    "# df3 给一班增加了两个考试科目\n",
    "df3 = pd.DataFrame(data = np.random.randint(0,150,size = (10,2)),\n",
    "                  index = list('ABCDEFGHIJ'),\n",
    "                  columns=['PyTorch','Paddle'])\n",
    "\n",
    "display(df1,df2,df3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cdcd305c",
   "metadata": {},
   "source": [
    "一班和二班成绩合并："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "f6f51047",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>63</td>\n",
       "      <td>136</td>\n",
       "      <td>116</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>133</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>35</td>\n",
       "      <td>57</td>\n",
       "      <td>82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>7</td>\n",
       "      <td>38</td>\n",
       "      <td>82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>89</td>\n",
       "      <td>111</td>\n",
       "      <td>101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>89</td>\n",
       "      <td>132</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>129</td>\n",
       "      <td>141</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>13</td>\n",
       "      <td>105</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>58</td>\n",
       "      <td>17</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>122</td>\n",
       "      <td>117</td>\n",
       "      <td>147</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>46</td>\n",
       "      <td>89</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>L</th>\n",
       "      <td>84</td>\n",
       "      <td>34</td>\n",
       "      <td>131</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>145</td>\n",
       "      <td>113</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>N</th>\n",
       "      <td>136</td>\n",
       "      <td>11</td>\n",
       "      <td>96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>O</th>\n",
       "      <td>94</td>\n",
       "      <td>8</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>P</th>\n",
       "      <td>25</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q</th>\n",
       "      <td>34</td>\n",
       "      <td>68</td>\n",
       "      <td>61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>R</th>\n",
       "      <td>36</td>\n",
       "      <td>40</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S</th>\n",
       "      <td>51</td>\n",
       "      <td>16</td>\n",
       "      <td>98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>87</td>\n",
       "      <td>30</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A      63         136    116\n",
       "B     133           1      9\n",
       "C      35          57     82\n",
       "D       7          38     82\n",
       "E      89         111    101\n",
       "F      89         132     10\n",
       "G     129         141     93\n",
       "H      13         105     93\n",
       "I      58          17     23\n",
       "J     122         117    147\n",
       "K      46          89     93\n",
       "L      84          34    131\n",
       "M     145         113     39\n",
       "N     136          11     96\n",
       "O      94           8     34\n",
       "P      25          10      3\n",
       "Q      34          68     61\n",
       "R      36          40     27\n",
       "S      51          16     98\n",
       "T      87          30     89"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# axis = 0表示 进行行合并\n",
    "pd.concat([df1,df2],axis = 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "9a0cb5c6",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/0q/2y7xgmvn00b1090yx3d_n1140000gn/T/ipykernel_58118/2885067130.py:1: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.\n",
      "  df1.append(df2) # 在df1后面追加df2\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>63</td>\n",
       "      <td>136</td>\n",
       "      <td>116</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>133</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>35</td>\n",
       "      <td>57</td>\n",
       "      <td>82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>7</td>\n",
       "      <td>38</td>\n",
       "      <td>82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>89</td>\n",
       "      <td>111</td>\n",
       "      <td>101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>89</td>\n",
       "      <td>132</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>129</td>\n",
       "      <td>141</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>13</td>\n",
       "      <td>105</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>58</td>\n",
       "      <td>17</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>122</td>\n",
       "      <td>117</td>\n",
       "      <td>147</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>46</td>\n",
       "      <td>89</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>L</th>\n",
       "      <td>84</td>\n",
       "      <td>34</td>\n",
       "      <td>131</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>145</td>\n",
       "      <td>113</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>N</th>\n",
       "      <td>136</td>\n",
       "      <td>11</td>\n",
       "      <td>96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>O</th>\n",
       "      <td>94</td>\n",
       "      <td>8</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>P</th>\n",
       "      <td>25</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q</th>\n",
       "      <td>34</td>\n",
       "      <td>68</td>\n",
       "      <td>61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>R</th>\n",
       "      <td>36</td>\n",
       "      <td>40</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S</th>\n",
       "      <td>51</td>\n",
       "      <td>16</td>\n",
       "      <td>98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>87</td>\n",
       "      <td>30</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A      63         136    116\n",
       "B     133           1      9\n",
       "C      35          57     82\n",
       "D       7          38     82\n",
       "E      89         111    101\n",
       "F      89         132     10\n",
       "G     129         141     93\n",
       "H      13         105     93\n",
       "I      58          17     23\n",
       "J     122         117    147\n",
       "K      46          89     93\n",
       "L      84          34    131\n",
       "M     145         113     39\n",
       "N     136          11     96\n",
       "O      94           8     34\n",
       "P      25          10      3\n",
       "Q      34          68     61\n",
       "R      36          40     27\n",
       "S      51          16     98\n",
       "T      87          30     89"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.append(df2) # 在df1后面追加df2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6b2cb9c8",
   "metadata": {},
   "source": [
    "一班科目增加，将原来的科目和增加的科目进行合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "8761192a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "      <th>PyTorch</th>\n",
       "      <th>Paddle</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>63</td>\n",
       "      <td>136</td>\n",
       "      <td>116</td>\n",
       "      <td>59</td>\n",
       "      <td>103</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>133</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "      <td>127</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>35</td>\n",
       "      <td>57</td>\n",
       "      <td>82</td>\n",
       "      <td>87</td>\n",
       "      <td>95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>7</td>\n",
       "      <td>38</td>\n",
       "      <td>82</td>\n",
       "      <td>8</td>\n",
       "      <td>69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>89</td>\n",
       "      <td>111</td>\n",
       "      <td>101</td>\n",
       "      <td>142</td>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>89</td>\n",
       "      <td>132</td>\n",
       "      <td>10</td>\n",
       "      <td>85</td>\n",
       "      <td>63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>129</td>\n",
       "      <td>141</td>\n",
       "      <td>93</td>\n",
       "      <td>140</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>13</td>\n",
       "      <td>105</td>\n",
       "      <td>93</td>\n",
       "      <td>46</td>\n",
       "      <td>57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>58</td>\n",
       "      <td>17</td>\n",
       "      <td>23</td>\n",
       "      <td>39</td>\n",
       "      <td>146</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>122</td>\n",
       "      <td>117</td>\n",
       "      <td>147</td>\n",
       "      <td>73</td>\n",
       "      <td>133</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras  PyTorch  Paddle\n",
       "A      63         136    116       59     103\n",
       "B     133           1      9      127      48\n",
       "C      35          57     82       87      95\n",
       "D       7          38     82        8      69\n",
       "E      89         111    101      142      88\n",
       "F      89         132     10       85      63\n",
       "G     129         141     93      140      49\n",
       "H      13         105     93       46      57\n",
       "I      58          17     23       39     146\n",
       "J     122         117    147       73     133"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 合并时，列增加，NaN表示空数据\n",
    "pd.concat([df1,df3],axis = 1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd9cecc1",
   "metadata": {},
   "source": [
    "## 插入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "10e31684",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Tensorflow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>19</td>\n",
       "      <td>38</td>\n",
       "      <td>99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>126</td>\n",
       "      <td>54</td>\n",
       "      <td>119</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>62</td>\n",
       "      <td>23</td>\n",
       "      <td>118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>142</td>\n",
       "      <td>18</td>\n",
       "      <td>128</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>143</td>\n",
       "      <td>107</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>16</td>\n",
       "      <td>59</td>\n",
       "      <td>112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>46</td>\n",
       "      <td>147</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>7</td>\n",
       "      <td>57</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>129</td>\n",
       "      <td>15</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>16</td>\n",
       "      <td>60</td>\n",
       "      <td>104</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Tensorflow\n",
       "A      19     38          99\n",
       "B     126     54         119\n",
       "C      62     23         118\n",
       "D     142     18         128\n",
       "E     143    107          40\n",
       "F      16     59         112\n",
       "G      46    147           9\n",
       "H       7     57          93\n",
       "I     129     15          41\n",
       "J      16     60         104"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "# 生成学生 各科的考试成绩\n",
    "df = pd.DataFrame(data = np.random.randint(0,151,size = (10,3)),\n",
    "                  index = list('ABCDEFGHIJ'),\n",
    "                  columns = ['Python','Keras','Tensorflow'])\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "ea6d745f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Math</th>\n",
       "      <th>Tensorflow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>19</td>\n",
       "      <td>38</td>\n",
       "      <td>150</td>\n",
       "      <td>99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>126</td>\n",
       "      <td>54</td>\n",
       "      <td>150</td>\n",
       "      <td>119</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>62</td>\n",
       "      <td>23</td>\n",
       "      <td>150</td>\n",
       "      <td>118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>142</td>\n",
       "      <td>18</td>\n",
       "      <td>150</td>\n",
       "      <td>128</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>143</td>\n",
       "      <td>107</td>\n",
       "      <td>150</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>16</td>\n",
       "      <td>59</td>\n",
       "      <td>150</td>\n",
       "      <td>112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>46</td>\n",
       "      <td>147</td>\n",
       "      <td>150</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>7</td>\n",
       "      <td>57</td>\n",
       "      <td>150</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>129</td>\n",
       "      <td>15</td>\n",
       "      <td>150</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>16</td>\n",
       "      <td>60</td>\n",
       "      <td>150</td>\n",
       "      <td>104</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Math  Tensorflow\n",
       "A      19     38   150          99\n",
       "B     126     54   150         119\n",
       "C      62     23   150         118\n",
       "D     142     18   150         128\n",
       "E     143    107   150          40\n",
       "F      16     59   150         112\n",
       "G      46    147   150           9\n",
       "H       7     57   150          93\n",
       "I     129     15   150          41\n",
       "J      16     60   150         104"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 在中间插入一列 Math成绩\n",
    "df.insert(loc = 2,column = 'Math',value = 150)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6b0ff45e",
   "metadata": {},
   "source": [
    "在Python后面插入一列，En："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "2671e6b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>En</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Math</th>\n",
       "      <th>Tensorflow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>19</td>\n",
       "      <td>31</td>\n",
       "      <td>38</td>\n",
       "      <td>150</td>\n",
       "      <td>99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>126</td>\n",
       "      <td>12</td>\n",
       "      <td>54</td>\n",
       "      <td>150</td>\n",
       "      <td>119</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>62</td>\n",
       "      <td>86</td>\n",
       "      <td>23</td>\n",
       "      <td>150</td>\n",
       "      <td>118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>142</td>\n",
       "      <td>26</td>\n",
       "      <td>18</td>\n",
       "      <td>150</td>\n",
       "      <td>128</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>143</td>\n",
       "      <td>81</td>\n",
       "      <td>107</td>\n",
       "      <td>150</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>16</td>\n",
       "      <td>145</td>\n",
       "      <td>59</td>\n",
       "      <td>150</td>\n",
       "      <td>112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>46</td>\n",
       "      <td>57</td>\n",
       "      <td>147</td>\n",
       "      <td>150</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "      <td>57</td>\n",
       "      <td>150</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>129</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "      <td>150</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>16</td>\n",
       "      <td>133</td>\n",
       "      <td>60</td>\n",
       "      <td>150</td>\n",
       "      <td>104</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python   En  Keras  Math  Tensorflow\n",
       "A      19   31     38   150          99\n",
       "B     126   12     54   150         119\n",
       "C      62   86     23   150         118\n",
       "D     142   26     18   150         128\n",
       "E     143   81    107   150          40\n",
       "F      16  145     59   150         112\n",
       "G      46   57    147   150           9\n",
       "H       7    9     57   150          93\n",
       "I     129   14     15   150          41\n",
       "J      16  133     60   150         104"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## 获取列索引\n",
    "# 1、转换成list列表\n",
    "# 2、调用index函数，获取列表中特定字段 Python的位置\n",
    "# 3、得到 En应该插入的位置\n",
    "index = list(df.columns).index('Python') + 1\n",
    "\n",
    "# value指定了随机数字\n",
    "df.insert(loc = index,column='En',value = np.random.randint(0,151,size = 10 ))\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "571a04f7",
   "metadata": {},
   "source": [
    "向TensorFlow后面插入一列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "060d4c22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>En</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Math</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>中文</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>19</td>\n",
       "      <td>31</td>\n",
       "      <td>38</td>\n",
       "      <td>150</td>\n",
       "      <td>99</td>\n",
       "      <td>63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>126</td>\n",
       "      <td>12</td>\n",
       "      <td>54</td>\n",
       "      <td>150</td>\n",
       "      <td>119</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>62</td>\n",
       "      <td>86</td>\n",
       "      <td>23</td>\n",
       "      <td>150</td>\n",
       "      <td>118</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>142</td>\n",
       "      <td>26</td>\n",
       "      <td>18</td>\n",
       "      <td>150</td>\n",
       "      <td>128</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>143</td>\n",
       "      <td>81</td>\n",
       "      <td>107</td>\n",
       "      <td>150</td>\n",
       "      <td>40</td>\n",
       "      <td>144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>16</td>\n",
       "      <td>145</td>\n",
       "      <td>59</td>\n",
       "      <td>150</td>\n",
       "      <td>112</td>\n",
       "      <td>64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>46</td>\n",
       "      <td>57</td>\n",
       "      <td>147</td>\n",
       "      <td>150</td>\n",
       "      <td>9</td>\n",
       "      <td>57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "      <td>57</td>\n",
       "      <td>150</td>\n",
       "      <td>93</td>\n",
       "      <td>130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>129</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "      <td>150</td>\n",
       "      <td>41</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>16</td>\n",
       "      <td>133</td>\n",
       "      <td>60</td>\n",
       "      <td>150</td>\n",
       "      <td>104</td>\n",
       "      <td>147</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python   En  Keras  Math  Tensorflow   中文\n",
       "A      19   31     38   150          99   63\n",
       "B     126   12     54   150         119    3\n",
       "C      62   86     23   150         118   90\n",
       "D     142   26     18   150         128   50\n",
       "E     143   81    107   150          40  144\n",
       "F      16  145     59   150         112   64\n",
       "G      46   57    147   150           9   57\n",
       "H       7    9     57   150          93  130\n",
       "I     129   14     15   150          41   89\n",
       "J      16  133     60   150         104  147"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## 获取列索引\n",
    "# 1、转换成list列表\n",
    "# 2、调用index函数，获取列表中特定字段 Tensorflow的位置\n",
    "# 3、得到应该插入的位置\n",
    "index = list(df.columns).index('Tensorflow') + 1\n",
    "\n",
    "# value指定了随机数字\n",
    "df.insert(loc = index,column='中文',value = np.random.randint(0,151,size = 10 ))\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c818c525",
   "metadata": {},
   "source": [
    "## join SQL数据库风格插入合并\n",
    "merge 合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "e5c98fa8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>weight</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>softpo</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Daniel</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Brandon</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ella</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      name  weight\n",
       "0   softpo      70\n",
       "1   Daniel      55\n",
       "2  Brandon      75\n",
       "3     Ella      65"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>height</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>softpo</td>\n",
       "      <td>172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Daniel</td>\n",
       "      <td>170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Brandon</td>\n",
       "      <td>170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Cindy</td>\n",
       "      <td>166</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      name  height\n",
       "0   softpo     172\n",
       "1   Daniel     170\n",
       "2  Brandon     170\n",
       "3    Cindy     166"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>名字</th>\n",
       "      <th>height</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>softpo</td>\n",
       "      <td>172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Daniel</td>\n",
       "      <td>170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Brandon</td>\n",
       "      <td>170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Cindy</td>\n",
       "      <td>166</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        名字  height\n",
       "0   softpo     172\n",
       "1   Daniel     170\n",
       "2  Brandon     170\n",
       "3    Cindy     166"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "# 表一中记录的是name和体重信息\n",
    "df1 = pd.DataFrame(data = {'name':['softpo','Daniel','Brandon','Ella'],'weight':[70,55,75,65]})\n",
    "\n",
    "# 表二中记录的是name和身高信息\n",
    "df2 = pd.DataFrame(data = {'name':['softpo','Daniel','Brandon','Cindy'],'height':[172,170,170,166]})\n",
    "df3 = pd.DataFrame(data = {'名字':['softpo','Daniel','Brandon','Cindy'],'height':[172,170,170,166]})\n",
    "\n",
    "display(df1,df2,df3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5a8098a9",
   "metadata": {},
   "source": [
    "df1、df2进行合并，df1表示体重、df2表示身高"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "6247ee10",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>weight</th>\n",
       "      <th>height</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>softpo</td>\n",
       "      <td>70</td>\n",
       "      <td>172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Daniel</td>\n",
       "      <td>55</td>\n",
       "      <td>170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Brandon</td>\n",
       "      <td>75</td>\n",
       "      <td>170</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      name  weight  height\n",
       "0   softpo      70     172\n",
       "1   Daniel      55     170\n",
       "2  Brandon      75     170"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(df1,df2,) \n",
    "# 根据共同的属性，进行合并\n",
    "# 共同的属性是name共同拥有的是：sotfpo、Daniel、Barandon"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "1f5e1275",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>weight</th>\n",
       "      <th>height</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>softpo</td>\n",
       "      <td>70</td>\n",
       "      <td>172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Daniel</td>\n",
       "      <td>55</td>\n",
       "      <td>170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Brandon</td>\n",
       "      <td>75</td>\n",
       "      <td>170</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      name  weight  height\n",
       "0   softpo      70     172\n",
       "1   Daniel      55     170\n",
       "2  Brandon      75     170"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 根据共同的name将俩表的数据，进行合并 \n",
    "pd.merge(df1, df2, \n",
    "         how = 'inner', # 内合并代表两对象交集，默认\n",
    "         on = 'name') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "ff3f755f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>weight</th>\n",
       "      <th>名字</th>\n",
       "      <th>height</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>softpo</td>\n",
       "      <td>70.0</td>\n",
       "      <td>softpo</td>\n",
       "      <td>172.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Daniel</td>\n",
       "      <td>55.0</td>\n",
       "      <td>Daniel</td>\n",
       "      <td>170.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Brandon</td>\n",
       "      <td>75.0</td>\n",
       "      <td>Brandon</td>\n",
       "      <td>170.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ella</td>\n",
       "      <td>65.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Cindy</td>\n",
       "      <td>166.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      name  weight       名字  height\n",
       "0   softpo    70.0   softpo   172.0\n",
       "1   Daniel    55.0   Daniel   170.0\n",
       "2  Brandon    75.0  Brandon   170.0\n",
       "3     Ella    65.0      NaN     NaN\n",
       "4      NaN     NaN    Cindy   166.0"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(df1, df3, how = 'outer', # 全外连接，两对象并集 \n",
    "         left_on = 'name', # 左边DataFrame使用列标签 name进行合并 \n",
    "         right_on = '名字') # 右边DataFrame使用列标签 名字进行合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "539a0f1a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>weight</th>\n",
       "      <th>名字</th>\n",
       "      <th>height</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>softpo</td>\n",
       "      <td>70</td>\n",
       "      <td>softpo</td>\n",
       "      <td>172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Daniel</td>\n",
       "      <td>55</td>\n",
       "      <td>Daniel</td>\n",
       "      <td>170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Brandon</td>\n",
       "      <td>75</td>\n",
       "      <td>Brandon</td>\n",
       "      <td>170</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      name  weight       名字  height\n",
       "0   softpo      70   softpo     172\n",
       "1   Daniel      55   Daniel     170\n",
       "2  Brandon      75  Brandon     170"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 指定了合并时，根据哪一列进行合并\n",
    "pd.merge(df1,df3,left_on = 'name',right_on = '名字')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1a9fdc05",
   "metadata": {},
   "source": [
    "10名同学，计算每个人平均分，合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "5d7903b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Tensorflow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>130</td>\n",
       "      <td>23</td>\n",
       "      <td>135</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>29</td>\n",
       "      <td>78</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>62</td>\n",
       "      <td>78</td>\n",
       "      <td>142</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>72</td>\n",
       "      <td>113</td>\n",
       "      <td>94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>30</td>\n",
       "      <td>93</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>78</td>\n",
       "      <td>28</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>52</td>\n",
       "      <td>110</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>128</td>\n",
       "      <td>36</td>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>124</td>\n",
       "      <td>87</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>45</td>\n",
       "      <td>88</td>\n",
       "      <td>95</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Tensorflow\n",
       "A     130     23         135\n",
       "B      29     78          13\n",
       "C      62     78         142\n",
       "D      72    113          94\n",
       "E      30     93          34\n",
       "F      78     28          70\n",
       "H      52    110          45\n",
       "I     128     36          67\n",
       "J     124     87          70\n",
       "K      45     88          95"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建10名学生的考试成绩\n",
    "df4 = pd.DataFrame(data = np.random.randint(0,151,size = (10,3)),\n",
    "                   index = list('ABCDEFHIJK'),\n",
    "                   columns=['Python','Keras','Tensorflow'])\n",
    "\n",
    "df4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "8015e1c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>平均值</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>96.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>40.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>94.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>93.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>52.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>58.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>69.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>77.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>93.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>76.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    平均值\n",
       "A  96.0\n",
       "B  40.0\n",
       "C  94.0\n",
       "D  93.0\n",
       "E  52.3\n",
       "F  58.7\n",
       "H  69.0\n",
       "I  77.0\n",
       "J  93.7\n",
       "K  76.0"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 计算出每个人的平均分，Series\n",
    "s = df4.mean(axis = 1).round(1)\n",
    "\n",
    "# 指定数据、列标签\n",
    "df5 = pd.DataFrame(s, columns=['平均值'])\n",
    "df5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "798533f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>平均值</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>130</td>\n",
       "      <td>23</td>\n",
       "      <td>135</td>\n",
       "      <td>96.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>29</td>\n",
       "      <td>78</td>\n",
       "      <td>13</td>\n",
       "      <td>40.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>62</td>\n",
       "      <td>78</td>\n",
       "      <td>142</td>\n",
       "      <td>94.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>72</td>\n",
       "      <td>113</td>\n",
       "      <td>94</td>\n",
       "      <td>93.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>30</td>\n",
       "      <td>93</td>\n",
       "      <td>34</td>\n",
       "      <td>52.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>78</td>\n",
       "      <td>28</td>\n",
       "      <td>70</td>\n",
       "      <td>58.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>52</td>\n",
       "      <td>110</td>\n",
       "      <td>45</td>\n",
       "      <td>69.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>128</td>\n",
       "      <td>36</td>\n",
       "      <td>67</td>\n",
       "      <td>77.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>124</td>\n",
       "      <td>87</td>\n",
       "      <td>70</td>\n",
       "      <td>93.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>45</td>\n",
       "      <td>88</td>\n",
       "      <td>95</td>\n",
       "      <td>76.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Tensorflow   平均值\n",
       "A     130     23         135  96.0\n",
       "B      29     78          13  40.0\n",
       "C      62     78         142  94.0\n",
       "D      72    113          94  93.0\n",
       "E      30     93          34  52.3\n",
       "F      78     28          70  58.7\n",
       "H      52    110          45  69.0\n",
       "I     128     36          67  77.0\n",
       "J     124     87          70  93.7\n",
       "K      45     88          95  76.0"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 根据某一列，进行合并,df4 和 df5没有共同的一列属性\n",
    "\n",
    "## 根据共同行索引进行合并\n",
    "# df4 行索引 A ~ K\n",
    "# df5 行索引 A ~ K\n",
    "pd.merge(df4,df5,left_index = True,right_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "6a899508",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>平均值</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>130</td>\n",
       "      <td>23</td>\n",
       "      <td>135</td>\n",
       "      <td>96.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>29</td>\n",
       "      <td>78</td>\n",
       "      <td>13</td>\n",
       "      <td>40.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>62</td>\n",
       "      <td>78</td>\n",
       "      <td>142</td>\n",
       "      <td>94.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>72</td>\n",
       "      <td>113</td>\n",
       "      <td>94</td>\n",
       "      <td>93.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>30</td>\n",
       "      <td>93</td>\n",
       "      <td>34</td>\n",
       "      <td>52.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>78</td>\n",
       "      <td>28</td>\n",
       "      <td>70</td>\n",
       "      <td>58.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>52</td>\n",
       "      <td>110</td>\n",
       "      <td>45</td>\n",
       "      <td>69.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>128</td>\n",
       "      <td>36</td>\n",
       "      <td>67</td>\n",
       "      <td>77.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>124</td>\n",
       "      <td>87</td>\n",
       "      <td>70</td>\n",
       "      <td>93.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>45</td>\n",
       "      <td>88</td>\n",
       "      <td>95</td>\n",
       "      <td>76.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Tensorflow   平均值\n",
       "A     130     23         135  96.0\n",
       "B      29     78          13  40.0\n",
       "C      62     78         142  94.0\n",
       "D      72    113          94  93.0\n",
       "E      30     93          34  52.3\n",
       "F      78     28          70  58.7\n",
       "H      52    110          45  69.0\n",
       "I     128     36          67  77.0\n",
       "J     124     87          70  93.7\n",
       "K      45     88          95  76.0"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([df4,df5],axis = 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "c216ccfa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>平均值</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>130</td>\n",
       "      <td>23</td>\n",
       "      <td>135</td>\n",
       "      <td>96.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>29</td>\n",
       "      <td>78</td>\n",
       "      <td>13</td>\n",
       "      <td>40.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>62</td>\n",
       "      <td>78</td>\n",
       "      <td>142</td>\n",
       "      <td>94.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>72</td>\n",
       "      <td>113</td>\n",
       "      <td>94</td>\n",
       "      <td>93.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>30</td>\n",
       "      <td>93</td>\n",
       "      <td>34</td>\n",
       "      <td>52.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>78</td>\n",
       "      <td>28</td>\n",
       "      <td>70</td>\n",
       "      <td>58.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>52</td>\n",
       "      <td>110</td>\n",
       "      <td>45</td>\n",
       "      <td>69.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>128</td>\n",
       "      <td>36</td>\n",
       "      <td>67</td>\n",
       "      <td>77.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>124</td>\n",
       "      <td>87</td>\n",
       "      <td>70</td>\n",
       "      <td>93.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>45</td>\n",
       "      <td>88</td>\n",
       "      <td>95</td>\n",
       "      <td>76.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Tensorflow   平均值\n",
       "A     130     23         135  96.0\n",
       "B      29     78          13  40.0\n",
       "C      62     78         142  94.0\n",
       "D      72    113          94  93.0\n",
       "E      30     93          34  52.3\n",
       "F      78     28          70  58.7\n",
       "H      52    110          45  69.0\n",
       "I     128     36          67  77.0\n",
       "J     124     87          70  93.7\n",
       "K      45     88          95  76.0"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df4.insert(loc = 3,column='平均值',value=df5)\n",
    "df4"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "64d8559c",
   "metadata": {},
   "source": [
    "# 数据清洗"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "3db40ab1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>color</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>red</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>blue</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>red</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>green</td>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>blue</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>None</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>red</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   color  price\n",
       "0    red   10.0\n",
       "1   blue   20.0\n",
       "2    red   10.0\n",
       "3  green   15.0\n",
       "4   blue   20.0\n",
       "5   None    0.0\n",
       "6    red    NaN\n",
       "7    NaN    NaN"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(data = {'color':['red','blue','red','green','blue',None,'red',np.NaN],\n",
    "                          'price':[10,20,10,15,20,0,np.NaN,None]}) # 数字，显示时候都是 NaN\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c828e75c",
   "metadata": {},
   "source": [
    "## 重复数据过滤"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "b904bb6a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    False\n",
       "1    False\n",
       "2     True\n",
       "3    False\n",
       "4     True\n",
       "5    False\n",
       "6    False\n",
       "7    False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "df.duplicated() # 判断是否存在重复数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "97bd2f7d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>color</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>red</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>blue</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>green</td>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>None</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>red</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   color  price\n",
       "0    red   10.0\n",
       "1   blue   20.0\n",
       "3  green   15.0\n",
       "5   None    0.0\n",
       "6    red    NaN\n",
       "7    NaN    NaN"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop_duplicates() # 删除重复数据"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "980a7455",
   "metadata": {},
   "source": [
    "## 空数据过滤"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "723ed6d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>color</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   color  price\n",
       "0  False  False\n",
       "1  False  False\n",
       "2  False  False\n",
       "3  False  False\n",
       "4  False  False\n",
       "5   True  False\n",
       "6  False   True\n",
       "7   True   True"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 判断是否是 空数据\n",
    "df.isnull()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "a3962b14",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>color</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>red</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>blue</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>red</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>green</td>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>blue</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   color  price\n",
       "0    red   10.0\n",
       "1   blue   20.0\n",
       "2    red   10.0\n",
       "3  green   15.0\n",
       "4   blue   20.0"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 去除空数据所在的行\n",
    "df.dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "617d522e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>color</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>red</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>blue</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>red</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>green</td>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>blue</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1024</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>red</td>\n",
       "      <td>1024.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1024</td>\n",
       "      <td>1024.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   color   price\n",
       "0    red    10.0\n",
       "1   blue    20.0\n",
       "2    red    10.0\n",
       "3  green    15.0\n",
       "4   blue    20.0\n",
       "5   1024     0.0\n",
       "6    red  1024.0\n",
       "7   1024  1024.0"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 将空数据填充为 1024\n",
    "df.fillna(1024)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "daa43975",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 3、指定行或者列进行过滤"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "930cc508",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>color</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>red</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>blue</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>red</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>green</td>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>blue</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>None</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>red</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   color  price\n",
       "0    red   10.0\n",
       "1   blue   20.0\n",
       "2    red   10.0\n",
       "3  green   15.0\n",
       "4   blue   20.0\n",
       "5   None    0.0\n",
       "6    red    NaN\n",
       "7    NaN    NaN"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "35bf8799",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   price\n",
       "0   10.0\n",
       "1   20.0\n",
       "2   10.0\n",
       "3   15.0\n",
       "4   20.0\n",
       "5    0.0\n",
       "6    NaN\n",
       "7    NaN"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "del df['color'] # 直接删除某列\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "875d54c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: []\n",
       "Index: [0, 1, 2, 3, 4, 5, 6, 7]"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# drop删除，返回删除之后的值，原来的数据没有修改\n",
    "df.drop(labels = ['price'],axis = 1)# 删除指定列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "id": "5359fd7b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   price\n",
       "0   10.0\n",
       "1   20.0\n",
       "2   10.0\n",
       "3   15.0\n",
       "4   20.0\n",
       "5    0.0\n",
       "6    NaN\n",
       "7    NaN"
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 没有修改原数据\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "dfc5d2d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   price\n",
       "2   10.0\n",
       "3   15.0\n",
       "4   20.0\n",
       "6    NaN\n",
       "7    NaN"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop(labels = [0, 1, 5],axis = 0) # 删除指定行，原来的数据不变"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "f3c19761",
   "metadata": {},
   "outputs": [],
   "source": [
    "# inplace 替换：替换原来数据，修改原数据\n",
    "df.drop(labels=[0,1,3,5],axis = 0,inplace=True) # 删除指定的行"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "811a8beb",
   "metadata": {},
   "source": [
    "## 异常值过滤"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "3cfb552e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.395681</td>\n",
       "      <td>-1.215539</td>\n",
       "      <td>1.160697</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-1.466641</td>\n",
       "      <td>1.770416</td>\n",
       "      <td>-1.255426</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-1.427945</td>\n",
       "      <td>0.001141</td>\n",
       "      <td>-0.739994</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-2.584596</td>\n",
       "      <td>-0.391065</td>\n",
       "      <td>-1.053883</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.729508</td>\n",
       "      <td>-0.994829</td>\n",
       "      <td>0.974780</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9995</th>\n",
       "      <td>-2.512910</td>\n",
       "      <td>1.886485</td>\n",
       "      <td>-0.823596</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9996</th>\n",
       "      <td>-1.381159</td>\n",
       "      <td>1.135156</td>\n",
       "      <td>-0.482940</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9997</th>\n",
       "      <td>-1.229758</td>\n",
       "      <td>0.844881</td>\n",
       "      <td>1.384736</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9998</th>\n",
       "      <td>0.760044</td>\n",
       "      <td>0.749274</td>\n",
       "      <td>2.194698</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9999</th>\n",
       "      <td>-0.695301</td>\n",
       "      <td>-1.093588</td>\n",
       "      <td>-1.246528</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10000 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             0         1         2\n",
       "0    -0.395681 -1.215539  1.160697\n",
       "1    -1.466641  1.770416 -1.255426\n",
       "2    -1.427945  0.001141 -0.739994\n",
       "3    -2.584596 -0.391065 -1.053883\n",
       "4    -0.729508 -0.994829  0.974780\n",
       "...        ...       ...       ...\n",
       "9995 -2.512910  1.886485 -0.823596\n",
       "9996 -1.381159  1.135156 -0.482940\n",
       "9997 -1.229758  0.844881  1.384736\n",
       "9998  0.760044  0.749274  2.194698\n",
       "9999 -0.695301 -1.093588 -1.246528\n",
       "\n",
       "[10000 rows x 3 columns]"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = pd.DataFrame(data = np.random.randn(10000,3)) # 生成正态分布的数据\n",
    "df2\n",
    "\n",
    "# 3σ过滤异常值，σ即是标准差\n",
    "# 1、cond = (df2 > 3 * df2.std()).any(axis = 1)\n",
    "# 2、index = df2[cond].index # 不满足条件的行索引\n",
    "# 3、df2.drop(labels=index, axis = 0) # 根据行索引，进行数据删除"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "0574f972",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0   -0.000704\n",
       "1   -0.012522\n",
       "2    0.013362\n",
       "dtype: float64"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.mean() # 平均值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "a4d95e05",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    1.001046\n",
       "1    0.996143\n",
       "2    1.000421\n",
       "dtype: float64"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.std() # 标准差"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f048bca2",
   "metadata": {},
   "source": [
    "$ > 3\\sigma$ 异常值 $\\sigma$ 表示标准差"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "cb2fc4b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>769</th>\n",
       "      <td>-3.203815</td>\n",
       "      <td>0.152925</td>\n",
       "      <td>0.612120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1616</th>\n",
       "      <td>-3.962832</td>\n",
       "      <td>2.364195</td>\n",
       "      <td>2.177614</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1794</th>\n",
       "      <td>3.349945</td>\n",
       "      <td>-1.825677</td>\n",
       "      <td>-0.713178</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1987</th>\n",
       "      <td>-3.324535</td>\n",
       "      <td>-1.449399</td>\n",
       "      <td>-0.503374</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2043</th>\n",
       "      <td>-3.204183</td>\n",
       "      <td>-1.291003</td>\n",
       "      <td>0.525508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2140</th>\n",
       "      <td>-3.793843</td>\n",
       "      <td>0.673858</td>\n",
       "      <td>1.018502</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2523</th>\n",
       "      <td>3.031251</td>\n",
       "      <td>-0.649879</td>\n",
       "      <td>-0.494512</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2546</th>\n",
       "      <td>3.171991</td>\n",
       "      <td>0.118679</td>\n",
       "      <td>-0.141047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2689</th>\n",
       "      <td>3.212692</td>\n",
       "      <td>1.569617</td>\n",
       "      <td>-1.497597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2731</th>\n",
       "      <td>-3.151261</td>\n",
       "      <td>-0.575618</td>\n",
       "      <td>0.132197</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3219</th>\n",
       "      <td>-3.011466</td>\n",
       "      <td>1.878531</td>\n",
       "      <td>1.739871</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3569</th>\n",
       "      <td>3.018700</td>\n",
       "      <td>0.047518</td>\n",
       "      <td>-0.948610</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3780</th>\n",
       "      <td>3.066939</td>\n",
       "      <td>-2.417975</td>\n",
       "      <td>-1.543111</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3812</th>\n",
       "      <td>-3.096289</td>\n",
       "      <td>-1.108456</td>\n",
       "      <td>1.149159</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4650</th>\n",
       "      <td>-3.110883</td>\n",
       "      <td>-1.476143</td>\n",
       "      <td>0.626979</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4660</th>\n",
       "      <td>3.048895</td>\n",
       "      <td>-0.541086</td>\n",
       "      <td>1.075373</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4913</th>\n",
       "      <td>3.122760</td>\n",
       "      <td>1.301907</td>\n",
       "      <td>1.076150</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5459</th>\n",
       "      <td>-3.670164</td>\n",
       "      <td>0.896145</td>\n",
       "      <td>0.119925</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5723</th>\n",
       "      <td>3.035917</td>\n",
       "      <td>-0.818822</td>\n",
       "      <td>1.208370</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6073</th>\n",
       "      <td>3.326605</td>\n",
       "      <td>0.513332</td>\n",
       "      <td>1.978319</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6153</th>\n",
       "      <td>3.196711</td>\n",
       "      <td>0.040790</td>\n",
       "      <td>-0.025074</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6222</th>\n",
       "      <td>-3.779705</td>\n",
       "      <td>-0.901778</td>\n",
       "      <td>-0.248304</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7281</th>\n",
       "      <td>3.100804</td>\n",
       "      <td>-0.181973</td>\n",
       "      <td>0.334376</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7516</th>\n",
       "      <td>-3.525040</td>\n",
       "      <td>-0.245890</td>\n",
       "      <td>0.144207</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8237</th>\n",
       "      <td>3.200481</td>\n",
       "      <td>-0.362631</td>\n",
       "      <td>0.629662</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8433</th>\n",
       "      <td>3.065964</td>\n",
       "      <td>0.747448</td>\n",
       "      <td>-0.897855</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8450</th>\n",
       "      <td>3.811653</td>\n",
       "      <td>-0.019303</td>\n",
       "      <td>-0.682559</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8925</th>\n",
       "      <td>3.663145</td>\n",
       "      <td>0.052594</td>\n",
       "      <td>1.475292</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9608</th>\n",
       "      <td>3.117171</td>\n",
       "      <td>-1.890761</td>\n",
       "      <td>0.204232</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             0         1         2\n",
       "769  -3.203815  0.152925  0.612120\n",
       "1616 -3.962832  2.364195  2.177614\n",
       "1794  3.349945 -1.825677 -0.713178\n",
       "1987 -3.324535 -1.449399 -0.503374\n",
       "2043 -3.204183 -1.291003  0.525508\n",
       "2140 -3.793843  0.673858  1.018502\n",
       "2523  3.031251 -0.649879 -0.494512\n",
       "2546  3.171991  0.118679 -0.141047\n",
       "2689  3.212692  1.569617 -1.497597\n",
       "2731 -3.151261 -0.575618  0.132197\n",
       "3219 -3.011466  1.878531  1.739871\n",
       "3569  3.018700  0.047518 -0.948610\n",
       "3780  3.066939 -2.417975 -1.543111\n",
       "3812 -3.096289 -1.108456  1.149159\n",
       "4650 -3.110883 -1.476143  0.626979\n",
       "4660  3.048895 -0.541086  1.075373\n",
       "4913  3.122760  1.301907  1.076150\n",
       "5459 -3.670164  0.896145  0.119925\n",
       "5723  3.035917 -0.818822  1.208370\n",
       "6073  3.326605  0.513332  1.978319\n",
       "6153  3.196711  0.040790 -0.025074\n",
       "6222 -3.779705 -0.901778 -0.248304\n",
       "7281  3.100804 -0.181973  0.334376\n",
       "7516 -3.525040 -0.245890  0.144207\n",
       "8237  3.200481 -0.362631  0.629662\n",
       "8433  3.065964  0.747448 -0.897855\n",
       "8450  3.811653 -0.019303 -0.682559\n",
       "8925  3.663145  0.052594  1.475292\n",
       "9608  3.117171 -1.890761  0.204232"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 取出行：0列中有异常值\n",
    "cond = df2.abs() > 3 * df2.std()\n",
    "cond_0 = cond[0]\n",
    "df2[cond_0]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "21c36f5d",
   "metadata": {},
   "source": [
    "获取每一列的异常"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "6d2d2a1d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.326833</td>\n",
       "      <td>1.473160</td>\n",
       "      <td>3.571423</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>552</th>\n",
       "      <td>-1.243104</td>\n",
       "      <td>3.067724</td>\n",
       "      <td>-1.583178</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>769</th>\n",
       "      <td>-3.203815</td>\n",
       "      <td>0.152925</td>\n",
       "      <td>0.612120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>879</th>\n",
       "      <td>0.612857</td>\n",
       "      <td>3.102390</td>\n",
       "      <td>-1.912109</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1058</th>\n",
       "      <td>0.818742</td>\n",
       "      <td>-0.737986</td>\n",
       "      <td>3.394559</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9098</th>\n",
       "      <td>0.412586</td>\n",
       "      <td>0.959032</td>\n",
       "      <td>3.247823</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9204</th>\n",
       "      <td>-0.595935</td>\n",
       "      <td>3.418658</td>\n",
       "      <td>1.296484</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9236</th>\n",
       "      <td>-0.294681</td>\n",
       "      <td>3.588806</td>\n",
       "      <td>1.349477</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9608</th>\n",
       "      <td>3.117171</td>\n",
       "      <td>-1.890761</td>\n",
       "      <td>0.204232</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9789</th>\n",
       "      <td>-0.716406</td>\n",
       "      <td>1.729847</td>\n",
       "      <td>3.142428</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>78 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             0         1         2\n",
       "15    0.326833  1.473160  3.571423\n",
       "552  -1.243104  3.067724 -1.583178\n",
       "769  -3.203815  0.152925  0.612120\n",
       "879   0.612857  3.102390 -1.912109\n",
       "1058  0.818742 -0.737986  3.394559\n",
       "...        ...       ...       ...\n",
       "9098  0.412586  0.959032  3.247823\n",
       "9204 -0.595935  3.418658  1.296484\n",
       "9236 -0.294681  3.588806  1.349477\n",
       "9608  3.117171 -1.890761  0.204232\n",
       "9789 -0.716406  1.729847  3.142428\n",
       "\n",
       "[78 rows x 3 columns]"
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cond = df2.abs() > 3 * df2.std()\n",
    "cond_0 = cond[0] # 默认[] 只能取列索引\n",
    "cond_1 = cond[1]\n",
    "cond_2 = cond[2]\n",
    "\n",
    "# 逻辑或运算，只要有一个满足，返回True\n",
    "cond_ = cond_0 | cond_1 | cond_2\n",
    "\n",
    "# 获取存在异常值的行\n",
    "df2[cond_]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "id": "f429516c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.326833</td>\n",
       "      <td>1.473160</td>\n",
       "      <td>3.571423</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>552</th>\n",
       "      <td>-1.243104</td>\n",
       "      <td>3.067724</td>\n",
       "      <td>-1.583178</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>769</th>\n",
       "      <td>-3.203815</td>\n",
       "      <td>0.152925</td>\n",
       "      <td>0.612120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>879</th>\n",
       "      <td>0.612857</td>\n",
       "      <td>3.102390</td>\n",
       "      <td>-1.912109</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1058</th>\n",
       "      <td>0.818742</td>\n",
       "      <td>-0.737986</td>\n",
       "      <td>3.394559</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9098</th>\n",
       "      <td>0.412586</td>\n",
       "      <td>0.959032</td>\n",
       "      <td>3.247823</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9204</th>\n",
       "      <td>-0.595935</td>\n",
       "      <td>3.418658</td>\n",
       "      <td>1.296484</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9236</th>\n",
       "      <td>-0.294681</td>\n",
       "      <td>3.588806</td>\n",
       "      <td>1.349477</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9608</th>\n",
       "      <td>3.117171</td>\n",
       "      <td>-1.890761</td>\n",
       "      <td>0.204232</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9789</th>\n",
       "      <td>-0.716406</td>\n",
       "      <td>1.729847</td>\n",
       "      <td>3.142428</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>78 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             0         1         2\n",
       "15    0.326833  1.473160  3.571423\n",
       "552  -1.243104  3.067724 -1.583178\n",
       "769  -3.203815  0.152925  0.612120\n",
       "879   0.612857  3.102390 -1.912109\n",
       "1058  0.818742 -0.737986  3.394559\n",
       "...        ...       ...       ...\n",
       "9098  0.412586  0.959032  3.247823\n",
       "9204 -0.595935  3.418658  1.296484\n",
       "9236 -0.294681  3.588806  1.349477\n",
       "9608  3.117171 -1.890761  0.204232\n",
       "9789 -0.716406  1.729847  3.142428\n",
       "\n",
       "[78 rows x 3 columns]"
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cond = df2.abs() > 3 * df2.std() # 是否是异常值\n",
    "\n",
    "# axis = 1计算每一行：只要一行中有一个TRUE，返回True\n",
    "# True，表示是异常值\n",
    "cond_ = cond.any(axis = 1) # 只要有一个为真,返回True\n",
    "\n",
    "# 获取存在异常值的行\n",
    "df2[cond_]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c890c02d",
   "metadata": {},
   "source": [
    "# 数据转换\n",
    "## 标签和元素替换"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "id": "57a14a1d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>5</td>\n",
       "      <td>8</td>\n",
       "      <td>7.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>9</td>\n",
       "      <td>7</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>4</td>\n",
       "      <td>8</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A       3           2    3.0\n",
       "B       5           8    7.0\n",
       "C       0           0    1.0\n",
       "D       1           7    4.0\n",
       "E       0           5    NaN\n",
       "F       5           9    5.0\n",
       "H       9           7    4.0\n",
       "I       3           3    9.0\n",
       "J       4           5    6.0\n",
       "K       4           8    5.0"
      ]
     },
     "execution_count": 117,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(data = np.random.randint(0,10,size = (10,3)), # 数据\n",
    "                  index = list('ABCDEFHIJK'), # 行标签\n",
    "                  columns=['Python','Tensorflow','Keras']) # 列标签\n",
    "\n",
    "# 设置空数据\n",
    "df.iloc[4,2] = None # 空数据\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "id": "cf34073a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>人工智能</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>AA</th>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>BB</th>\n",
       "      <td>5</td>\n",
       "      <td>8</td>\n",
       "      <td>7.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>9</td>\n",
       "      <td>7</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>4</td>\n",
       "      <td>8</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    人工智能  Tensorflow  Keras\n",
       "AA     3           2    3.0\n",
       "BB     5           8    7.0\n",
       "C      0           0    1.0\n",
       "D      1           7    4.0\n",
       "E      0           5    NaN\n",
       "F      5           9    5.0\n",
       "H      9           7    4.0\n",
       "I      3           3    9.0\n",
       "J      4           5    6.0\n",
       "K      4           8    5.0"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1、重命名索引\n",
    "df.rename(index = {'A':'AA','B':'BB'},\n",
    "          columns = {'Python':'人工智能'}) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "id": "6d7ef663",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>5</td>\n",
       "      <td>8</td>\n",
       "      <td>7.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>-1024</td>\n",
       "      <td>7</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>9</td>\n",
       "      <td>7</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>4</td>\n",
       "      <td>8</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A       3           2    3.0\n",
       "B       5           8    7.0\n",
       "C       0           0    1.0\n",
       "D   -1024           7    4.0\n",
       "E       0           5    NaN\n",
       "F       5           9    5.0\n",
       "H       9           7    4.0\n",
       "I       3           3    9.0\n",
       "J       4           5    6.0\n",
       "K       4           8    5.0"
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 2、替换值，replace不改变原数据\n",
    "df.replace(5,1024) # 将5替换为1024\n",
    "df.replace([0,7],2048) # 将0和7替换为2048\n",
    "df.replace({0:512, np.nan:998}) # 根据字典键值对进行替换\n",
    "\n",
    "df.replace({'Python':1},-1024) # 将Python这一列中等于1的，替换为-1024"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "defb0e0b",
   "metadata": {},
   "source": [
    "## map Series元素改变"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "26477156",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>9</td>\n",
       "      <td>7</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>7.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>4</td>\n",
       "      <td>8</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A       9           7    1.0\n",
       "B       5           3    9.0\n",
       "C       7           0    6.0\n",
       "D       3           0    5.0\n",
       "E       2           2    NaN\n",
       "F       8           6    2.0\n",
       "H       0           6    1.0\n",
       "I       6           7    7.0\n",
       "J       7           2    2.0\n",
       "K       4           8    1.0"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(data = np.random.randint(0,10,size = (10,3)),\n",
    "                  index = list('ABCDEFHIJK'),\n",
    "                  columns=['Python','Tensorflow','Keras'])\n",
    "\n",
    "df.iloc[4,2] = None # 空数据\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "0f258b7c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A      NaN\n",
       "B    Hello\n",
       "C      NaN\n",
       "D    World\n",
       "E       AI\n",
       "F      NaN\n",
       "H      NaN\n",
       "I      NaN\n",
       "J      NaN\n",
       "K      NaN\n",
       "Name: Keras, dtype: object"
      ]
     },
     "execution_count": 122,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1、map批量元素改变，Series专有\n",
    "df['Keras'].map({9:'Hello',5:'World',np.NaN:'AI'}) # 字典映射，没映射的数据变为 NaN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "c2f41893",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A      1.0\n",
       "B    Hello\n",
       "C      6.0\n",
       "D    World\n",
       "E      NaN\n",
       "F      2.0\n",
       "H      1.0\n",
       "I      7.0\n",
       "J      2.0\n",
       "K      1.0\n",
       "Name: Keras, dtype: object"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 通过函数替换数据\n",
    "def convert(x):\n",
    "    if x == 9:\n",
    "        return 'Hello'\n",
    "    elif x == 5:\n",
    "        return 'World'\n",
    "    elif x is np.NaN:\n",
    "        return 'AI'\n",
    "    else:\n",
    "        return x\n",
    "df['Keras'].map(convert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "id": "4ce43c17",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A    100\n",
       "B    100\n",
       "C    100\n",
       "D   -100\n",
       "E   -100\n",
       "F    100\n",
       "H   -100\n",
       "I    100\n",
       "J    100\n",
       "K   -100\n",
       "Name: Python, dtype: int64"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 隐式函数映射，利用lambda\n",
    "df['Python'].map(lambda x:100 if x >=5 else -100) "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "812c69f3",
   "metadata": {},
   "source": [
    "## apply、applymap、map改变元素\n",
    "既支持 Series，也支持 DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "id": "d7b41146",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>31</td>\n",
       "      <td>1</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>71</td>\n",
       "      <td>69</td>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>92</td>\n",
       "      <td>24</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>52</td>\n",
       "      <td>16</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>85</td>\n",
       "      <td>95</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>85</td>\n",
       "      <td>40</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>44</td>\n",
       "      <td>38</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>44</td>\n",
       "      <td>55</td>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>67</td>\n",
       "      <td>41</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>61</td>\n",
       "      <td>18</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>51</td>\n",
       "      <td>4</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>55</td>\n",
       "      <td>92</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>20</td>\n",
       "      <td>4</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>60</td>\n",
       "      <td>8</td>\n",
       "      <td>91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>27</td>\n",
       "      <td>28</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>67</td>\n",
       "      <td>61</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>79</td>\n",
       "      <td>87</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>57</td>\n",
       "      <td>73</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>13</td>\n",
       "      <td>66</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>48</td>\n",
       "      <td>83</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>12</td>\n",
       "      <td>42</td>\n",
       "      <td>82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>74</td>\n",
       "      <td>67</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>46</td>\n",
       "      <td>70</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>77</td>\n",
       "      <td>49</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>11</td>\n",
       "      <td>4</td>\n",
       "      <td>91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>73</td>\n",
       "      <td>16</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>8</td>\n",
       "      <td>85</td>\n",
       "      <td>99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>79</td>\n",
       "      <td>41</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>84</td>\n",
       "      <td>39</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>47</td>\n",
       "      <td>73</td>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python  Math  En\n",
       "0       31     1  44\n",
       "1       71    69  67\n",
       "2       92    24  31\n",
       "3       52    16  56\n",
       "4       85    95  48\n",
       "5       85    40  35\n",
       "6       44    38  90\n",
       "7       44    55  80\n",
       "8       67    41  42\n",
       "9       61    18  37\n",
       "10      51     4  73\n",
       "11      55    92  73\n",
       "12      20     4  43\n",
       "13      60     8  91\n",
       "14      27    28  48\n",
       "15      67    61  56\n",
       "16      79    87  42\n",
       "17      57    73   5\n",
       "18      13    66   5\n",
       "19      48    83  73\n",
       "20      12    42  82\n",
       "21      74    67  65\n",
       "22      46    70  36\n",
       "23      77    49  73\n",
       "24      11     4  91\n",
       "25      73    16  37\n",
       "26       8    85  99\n",
       "27      79    41  35\n",
       "28      84    39  45\n",
       "29      47    73  84"
      ]
     },
     "execution_count": 125,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "df = pd.DataFrame(np.random.randint(0,100,size = (30,3)), # 数据\n",
    "                  columns=['Python','Math','En']) # 标签\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "id": "37b08a45",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     不及格\n",
       "1      中等\n",
       "2      优秀\n",
       "3     不及格\n",
       "4      优秀\n",
       "5      优秀\n",
       "6     不及格\n",
       "7     不及格\n",
       "8      中等\n",
       "9      中等\n",
       "10    不及格\n",
       "11    不及格\n",
       "12    不及格\n",
       "13     中等\n",
       "14    不及格\n",
       "15     中等\n",
       "16     中等\n",
       "17    不及格\n",
       "18    不及格\n",
       "19    不及格\n",
       "20    不及格\n",
       "21     中等\n",
       "22    不及格\n",
       "23     中等\n",
       "24    不及格\n",
       "25     中等\n",
       "26    不及格\n",
       "27     中等\n",
       "28     优秀\n",
       "29    不及格\n",
       "Name: Python, dtype: object"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def convert(x):\n",
    "    if x < 60:\n",
    "        return '不及格' \n",
    "    elif x < 80: \n",
    "        return '中等'\n",
    "    else:\n",
    "        return '优秀'\n",
    "    \n",
    "# 根据规则，进行数据转换\n",
    "result = df['Python'].apply(convert)\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "id": "aab65339",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Python等级</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>31</td>\n",
       "      <td>不及格</td>\n",
       "      <td>1</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>71</td>\n",
       "      <td>中等</td>\n",
       "      <td>69</td>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>92</td>\n",
       "      <td>优秀</td>\n",
       "      <td>24</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>52</td>\n",
       "      <td>不及格</td>\n",
       "      <td>16</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>85</td>\n",
       "      <td>优秀</td>\n",
       "      <td>95</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>85</td>\n",
       "      <td>优秀</td>\n",
       "      <td>40</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>44</td>\n",
       "      <td>不及格</td>\n",
       "      <td>38</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>44</td>\n",
       "      <td>不及格</td>\n",
       "      <td>55</td>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>67</td>\n",
       "      <td>中等</td>\n",
       "      <td>41</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>61</td>\n",
       "      <td>中等</td>\n",
       "      <td>18</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>51</td>\n",
       "      <td>不及格</td>\n",
       "      <td>4</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>55</td>\n",
       "      <td>不及格</td>\n",
       "      <td>92</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>20</td>\n",
       "      <td>不及格</td>\n",
       "      <td>4</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>60</td>\n",
       "      <td>中等</td>\n",
       "      <td>8</td>\n",
       "      <td>91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>27</td>\n",
       "      <td>不及格</td>\n",
       "      <td>28</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>67</td>\n",
       "      <td>中等</td>\n",
       "      <td>61</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>79</td>\n",
       "      <td>中等</td>\n",
       "      <td>87</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>57</td>\n",
       "      <td>不及格</td>\n",
       "      <td>73</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>13</td>\n",
       "      <td>不及格</td>\n",
       "      <td>66</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>48</td>\n",
       "      <td>不及格</td>\n",
       "      <td>83</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>12</td>\n",
       "      <td>不及格</td>\n",
       "      <td>42</td>\n",
       "      <td>82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>74</td>\n",
       "      <td>中等</td>\n",
       "      <td>67</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>46</td>\n",
       "      <td>不及格</td>\n",
       "      <td>70</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>77</td>\n",
       "      <td>中等</td>\n",
       "      <td>49</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>11</td>\n",
       "      <td>不及格</td>\n",
       "      <td>4</td>\n",
       "      <td>91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>73</td>\n",
       "      <td>中等</td>\n",
       "      <td>16</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>8</td>\n",
       "      <td>不及格</td>\n",
       "      <td>85</td>\n",
       "      <td>99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>79</td>\n",
       "      <td>中等</td>\n",
       "      <td>41</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>84</td>\n",
       "      <td>优秀</td>\n",
       "      <td>39</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>47</td>\n",
       "      <td>不及格</td>\n",
       "      <td>73</td>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python Python等级  Math  En\n",
       "0       31      不及格     1  44\n",
       "1       71       中等    69  67\n",
       "2       92       优秀    24  31\n",
       "3       52      不及格    16  56\n",
       "4       85       优秀    95  48\n",
       "5       85       优秀    40  35\n",
       "6       44      不及格    38  90\n",
       "7       44      不及格    55  80\n",
       "8       67       中等    41  42\n",
       "9       61       中等    18  37\n",
       "10      51      不及格     4  73\n",
       "11      55      不及格    92  73\n",
       "12      20      不及格     4  43\n",
       "13      60       中等     8  91\n",
       "14      27      不及格    28  48\n",
       "15      67       中等    61  56\n",
       "16      79       中等    87  42\n",
       "17      57      不及格    73   5\n",
       "18      13      不及格    66   5\n",
       "19      48      不及格    83  73\n",
       "20      12      不及格    42  82\n",
       "21      74       中等    67  65\n",
       "22      46      不及格    70  36\n",
       "23      77       中等    49  73\n",
       "24      11      不及格     4  91\n",
       "25      73       中等    16  37\n",
       "26       8      不及格    85  99\n",
       "27      79       中等    41  35\n",
       "28      84       优秀    39  45\n",
       "29      47      不及格    73  84"
      ]
     },
     "execution_count": 127,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 在 Python 后面插入 ‘Python等级’\n",
    "index = list(df.columns).index('Python') + 1\n",
    "\n",
    "df.insert(loc = index, column = 'Python' + '等级', value = result)\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "78ebaac4",
   "metadata": {},
   "source": [
    "多行转换"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "id": "dc259258",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>Python</th>\n",
       "      <th>Python级别</th>\n",
       "      <th>Python等级</th>\n",
       "      <th>Math</th>\n",
       "      <th>Math级别</th>\n",
       "      <th>En</th>\n",
       "      <th>En级别</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>31</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>1</td>\n",
       "      <td>不及格</td>\n",
       "      <td>44</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>71</td>\n",
       "      <td>中等</td>\n",
       "      <td>中等</td>\n",
       "      <td>69</td>\n",
       "      <td>中等</td>\n",
       "      <td>67</td>\n",
       "      <td>中等</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>92</td>\n",
       "      <td>优秀</td>\n",
       "      <td>优秀</td>\n",
       "      <td>24</td>\n",
       "      <td>不及格</td>\n",
       "      <td>31</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>52</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>16</td>\n",
       "      <td>不及格</td>\n",
       "      <td>56</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>85</td>\n",
       "      <td>优秀</td>\n",
       "      <td>优秀</td>\n",
       "      <td>95</td>\n",
       "      <td>优秀</td>\n",
       "      <td>48</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5</td>\n",
       "      <td>85</td>\n",
       "      <td>优秀</td>\n",
       "      <td>优秀</td>\n",
       "      <td>40</td>\n",
       "      <td>不及格</td>\n",
       "      <td>35</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>6</td>\n",
       "      <td>44</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>38</td>\n",
       "      <td>不及格</td>\n",
       "      <td>90</td>\n",
       "      <td>优秀</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>7</td>\n",
       "      <td>44</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>55</td>\n",
       "      <td>不及格</td>\n",
       "      <td>80</td>\n",
       "      <td>优秀</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>8</td>\n",
       "      <td>67</td>\n",
       "      <td>中等</td>\n",
       "      <td>中等</td>\n",
       "      <td>41</td>\n",
       "      <td>不及格</td>\n",
       "      <td>42</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>9</td>\n",
       "      <td>61</td>\n",
       "      <td>中等</td>\n",
       "      <td>中等</td>\n",
       "      <td>18</td>\n",
       "      <td>不及格</td>\n",
       "      <td>37</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>10</td>\n",
       "      <td>51</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>4</td>\n",
       "      <td>不及格</td>\n",
       "      <td>73</td>\n",
       "      <td>中等</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>11</td>\n",
       "      <td>55</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>92</td>\n",
       "      <td>优秀</td>\n",
       "      <td>73</td>\n",
       "      <td>中等</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>12</td>\n",
       "      <td>20</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>4</td>\n",
       "      <td>不及格</td>\n",
       "      <td>43</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>13</td>\n",
       "      <td>60</td>\n",
       "      <td>中等</td>\n",
       "      <td>中等</td>\n",
       "      <td>8</td>\n",
       "      <td>不及格</td>\n",
       "      <td>91</td>\n",
       "      <td>优秀</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>14</td>\n",
       "      <td>27</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>28</td>\n",
       "      <td>不及格</td>\n",
       "      <td>48</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>15</td>\n",
       "      <td>67</td>\n",
       "      <td>中等</td>\n",
       "      <td>中等</td>\n",
       "      <td>61</td>\n",
       "      <td>中等</td>\n",
       "      <td>56</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>16</td>\n",
       "      <td>79</td>\n",
       "      <td>中等</td>\n",
       "      <td>中等</td>\n",
       "      <td>87</td>\n",
       "      <td>优秀</td>\n",
       "      <td>42</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>17</td>\n",
       "      <td>57</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>73</td>\n",
       "      <td>中等</td>\n",
       "      <td>5</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>18</td>\n",
       "      <td>13</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>66</td>\n",
       "      <td>中等</td>\n",
       "      <td>5</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>19</td>\n",
       "      <td>48</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>83</td>\n",
       "      <td>优秀</td>\n",
       "      <td>73</td>\n",
       "      <td>中等</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>20</td>\n",
       "      <td>12</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>42</td>\n",
       "      <td>不及格</td>\n",
       "      <td>82</td>\n",
       "      <td>优秀</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>21</td>\n",
       "      <td>74</td>\n",
       "      <td>中等</td>\n",
       "      <td>中等</td>\n",
       "      <td>67</td>\n",
       "      <td>中等</td>\n",
       "      <td>65</td>\n",
       "      <td>中等</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>22</td>\n",
       "      <td>46</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>70</td>\n",
       "      <td>中等</td>\n",
       "      <td>36</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>23</td>\n",
       "      <td>77</td>\n",
       "      <td>中等</td>\n",
       "      <td>中等</td>\n",
       "      <td>49</td>\n",
       "      <td>不及格</td>\n",
       "      <td>73</td>\n",
       "      <td>中等</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>24</td>\n",
       "      <td>11</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>4</td>\n",
       "      <td>不及格</td>\n",
       "      <td>91</td>\n",
       "      <td>优秀</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>25</td>\n",
       "      <td>73</td>\n",
       "      <td>中等</td>\n",
       "      <td>中等</td>\n",
       "      <td>16</td>\n",
       "      <td>不及格</td>\n",
       "      <td>37</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>26</td>\n",
       "      <td>8</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>85</td>\n",
       "      <td>优秀</td>\n",
       "      <td>99</td>\n",
       "      <td>优秀</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>27</td>\n",
       "      <td>79</td>\n",
       "      <td>中等</td>\n",
       "      <td>中等</td>\n",
       "      <td>41</td>\n",
       "      <td>不及格</td>\n",
       "      <td>35</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>28</td>\n",
       "      <td>84</td>\n",
       "      <td>优秀</td>\n",
       "      <td>优秀</td>\n",
       "      <td>39</td>\n",
       "      <td>不及格</td>\n",
       "      <td>45</td>\n",
       "      <td>不及格</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>29</td>\n",
       "      <td>47</td>\n",
       "      <td>不及格</td>\n",
       "      <td>不及格</td>\n",
       "      <td>73</td>\n",
       "      <td>中等</td>\n",
       "      <td>84</td>\n",
       "      <td>优秀</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Unnamed: 0  Python Python级别 Python等级  Math Math级别  En En级别\n",
       "0            0      31      不及格      不及格     1    不及格  44  不及格\n",
       "1            1      71       中等       中等    69     中等  67   中等\n",
       "2            2      92       优秀       优秀    24    不及格  31  不及格\n",
       "3            3      52      不及格      不及格    16    不及格  56  不及格\n",
       "4            4      85       优秀       优秀    95     优秀  48  不及格\n",
       "5            5      85       优秀       优秀    40    不及格  35  不及格\n",
       "6            6      44      不及格      不及格    38    不及格  90   优秀\n",
       "7            7      44      不及格      不及格    55    不及格  80   优秀\n",
       "8            8      67       中等       中等    41    不及格  42  不及格\n",
       "9            9      61       中等       中等    18    不及格  37  不及格\n",
       "10          10      51      不及格      不及格     4    不及格  73   中等\n",
       "11          11      55      不及格      不及格    92     优秀  73   中等\n",
       "12          12      20      不及格      不及格     4    不及格  43  不及格\n",
       "13          13      60       中等       中等     8    不及格  91   优秀\n",
       "14          14      27      不及格      不及格    28    不及格  48  不及格\n",
       "15          15      67       中等       中等    61     中等  56  不及格\n",
       "16          16      79       中等       中等    87     优秀  42  不及格\n",
       "17          17      57      不及格      不及格    73     中等   5  不及格\n",
       "18          18      13      不及格      不及格    66     中等   5  不及格\n",
       "19          19      48      不及格      不及格    83     优秀  73   中等\n",
       "20          20      12      不及格      不及格    42    不及格  82   优秀\n",
       "21          21      74       中等       中等    67     中等  65   中等\n",
       "22          22      46      不及格      不及格    70     中等  36  不及格\n",
       "23          23      77       中等       中等    49    不及格  73   中等\n",
       "24          24      11      不及格      不及格     4    不及格  91   优秀\n",
       "25          25      73       中等       中等    16    不及格  37  不及格\n",
       "26          26       8      不及格      不及格    85     优秀  99   优秀\n",
       "27          27      79       中等       中等    41    不及格  35  不及格\n",
       "28          28      84       优秀       优秀    39    不及格  45  不及格\n",
       "29          29      47      不及格      不及格    73     中等  84   优秀"
      ]
     },
     "execution_count": 135,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def convert(x):\n",
    "    if x < 60:\n",
    "        return '不及格' \n",
    "    elif x < 80: \n",
    "        return '中等'\n",
    "    else:\n",
    "        return '优秀'\n",
    "\n",
    "for col in ['Python','Math','En']: # 遍历要变换的列\n",
    "    # 根据规则，进行数据转换\n",
    "    result = df[col].apply(convert)\n",
    "\n",
    "    # 计算插入位置的索引，使用变量表示\n",
    "    index = list(df.columns).index(col) + 1\n",
    "    \n",
    "    # 插入\n",
    "    df.insert(loc = index,column = col + '级别',value = result)\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "456a0293",
   "metadata": {},
   "source": [
    "apply、applymap应用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "id": "54422428",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A       1           5      7\n",
       "B       0           9      2\n",
       "C       6           8      5\n",
       "D       8           1      6\n",
       "E       5           2      7\n",
       "F       6           8      8\n",
       "H       5           6      9\n",
       "I       4           6      8\n",
       "J       5           9      3\n",
       "K       6           0      8"
      ]
     },
     "execution_count": 136,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(data = np.random.randint(0,10,size = (10,3)), # 数据\n",
    "                  index = list('ABCDEFHIJK'), # 行标签\n",
    "                  columns=['Python','Tensorflow','Keras']) # 列标签\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "id": "ea2587dd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>101</td>\n",
       "      <td>5</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>100</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>106</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>108</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>105</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>106</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>105</td>\n",
       "      <td>6</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>104</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>105</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>106</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A     101           5      7\n",
       "B     100           9      2\n",
       "C     106           8      5\n",
       "D     108           1      6\n",
       "E     105           2      7\n",
       "F     106           8      8\n",
       "H     105           6      9\n",
       "I     104           6      8\n",
       "J     105           9      3\n",
       "K     106           0      8"
      ]
     },
     "execution_count": 137,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# apply应用，方法：自定义、简单隐式函数（lambda）\n",
    "# 将 Python 的分数 +100\n",
    "df['Python'] = df['Python'].apply(lambda x : x + 100)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "id": "4b2cf840",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A       1           5      7\n",
       "B       0           9      2\n",
       "C       6           8      5\n",
       "D       8           1      6\n",
       "E       5           2      7\n",
       "F       6           8      8\n",
       "H       5           6      9\n",
       "I       4           6      8\n",
       "J       5           9      3\n",
       "K       6           0      8"
      ]
     },
     "execution_count": 138,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 利用 map，将 Python的分数 -100\n",
    "df['Python'] = df['Python'].map(lambda x : x - 100)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "401cd833",
   "metadata": {},
   "source": [
    "applymap它可以对整个DataFrame进行全部处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "id": "2d36d21d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>100</td>\n",
       "      <td>-100</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>100</td>\n",
       "      <td>-100</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>-100</td>\n",
       "      <td>-100</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>-100</td>\n",
       "      <td>100</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>-100</td>\n",
       "      <td>100</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>-100</td>\n",
       "      <td>-100</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>-100</td>\n",
       "      <td>-100</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>100</td>\n",
       "      <td>-100</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>-100</td>\n",
       "      <td>-100</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>-100</td>\n",
       "      <td>100</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A     100        -100   -100\n",
       "B     100        -100    100\n",
       "C    -100        -100   -100\n",
       "D    -100         100   -100\n",
       "E    -100         100   -100\n",
       "F    -100        -100   -100\n",
       "H    -100        -100   -100\n",
       "I     100        -100   -100\n",
       "J    -100        -100    100\n",
       "K    -100         100   -100"
      ]
     },
     "execution_count": 139,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def convert(x):\n",
    "    if x < 5:\n",
    "        return 100\n",
    "    else:\n",
    "        return -100\n",
    "df.applymap(convert)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89b915b3",
   "metadata": {},
   "source": [
    "## transform"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "id": "4c6128e5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>8.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>6</td>\n",
       "      <td>9</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A       8           6    1.0\n",
       "B       0           4    8.0\n",
       "C       7           0    2.0\n",
       "D       1           9    1.0\n",
       "E       9           9    NaN\n",
       "F       7           3    3.0\n",
       "H       3           2    1.0\n",
       "I       3           5    1.0\n",
       "J       0           4    6.0\n",
       "K       6           9    9.0"
      ]
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(data = np.random.randint(0,10,size = (10,3)), # 数据\n",
    "                  index = list('ABCDEFHIJK'), # 行索引\n",
    "                  columns=['Python','Tensorflow','Keras']) # 列索引\n",
    "df.iloc[4,2] = None # 空数据\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "id": "b5f504d2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A    18\n",
       "B    10\n",
       "C    17\n",
       "D    11\n",
       "E    19\n",
       "F    17\n",
       "H    13\n",
       "I    13\n",
       "J    10\n",
       "K    16\n",
       "Name: Python, dtype: int64"
      ]
     },
     "execution_count": 141,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 将 Python 成绩 +10\n",
    "df['Python'].transform(lambda x : x+10) # 不改变原数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "id": "b3f2aa46",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A   -100\n",
       "B    100\n",
       "C   -100\n",
       "D    100\n",
       "E   -100\n",
       "F   -100\n",
       "H    100\n",
       "I    100\n",
       "J    100\n",
       "K   -100\n",
       "Name: Python, dtype: int64"
      ]
     },
     "execution_count": 144,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 利用函数进行变换\n",
    "def convert(x):\n",
    "    if x < 5:\n",
    "        return 100\n",
    "    else:\n",
    "        return -100\n",
    "    \n",
    "df['Python'].transform(convert)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "efd4adb2",
   "metadata": {},
   "source": [
    "对一列，进行不同的操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "id": "d63d12ef",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sqrt</th>\n",
       "      <th>exp</th>\n",
       "      <th>convert</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>2.828427</td>\n",
       "      <td>2980.957987</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>2.645751</td>\n",
       "      <td>1096.633158</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.718282</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>3.000000</td>\n",
       "      <td>8103.083928</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>2.645751</td>\n",
       "      <td>1096.633158</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>1.732051</td>\n",
       "      <td>20.085537</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>1.732051</td>\n",
       "      <td>20.085537</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>2.449490</td>\n",
       "      <td>403.428793</td>\n",
       "      <td>-100</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       sqrt          exp  convert\n",
       "A  2.828427  2980.957987     -100\n",
       "B  0.000000     1.000000      100\n",
       "C  2.645751  1096.633158     -100\n",
       "D  1.000000     2.718282      100\n",
       "E  3.000000  8103.083928     -100\n",
       "F  2.645751  1096.633158     -100\n",
       "H  1.732051    20.085537      100\n",
       "I  1.732051    20.085537      100\n",
       "J  0.000000     1.000000      100\n",
       "K  2.449490   403.428793     -100"
      ]
     },
     "execution_count": 145,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Python'].transform([np.sqrt, np.exp, convert])# 开平方，幂运算自然底数e，函数运算"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3da45bff",
   "metadata": {},
   "source": [
    "对多列，进行不同的操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "id": "def3e5a1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>2980.957987</td>\n",
       "      <td>16</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>14</td>\n",
       "      <td>2.828427</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>1096.633158</td>\n",
       "      <td>10</td>\n",
       "      <td>1.414214</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>2.718282</td>\n",
       "      <td>19</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>8103.083928</td>\n",
       "      <td>19</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>1096.633158</td>\n",
       "      <td>13</td>\n",
       "      <td>1.732051</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>20.085537</td>\n",
       "      <td>12</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>20.085537</td>\n",
       "      <td>15</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>14</td>\n",
       "      <td>2.449490</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>403.428793</td>\n",
       "      <td>19</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Python  Tensorflow     Keras\n",
       "A  2980.957987          16  1.000000\n",
       "B     1.000000          14  2.828427\n",
       "C  1096.633158          10  1.414214\n",
       "D     2.718282          19  1.000000\n",
       "E  8103.083928          19       NaN\n",
       "F  1096.633158          13  1.732051\n",
       "H    20.085537          12  1.000000\n",
       "I    20.085537          15  1.000000\n",
       "J     1.000000          14  2.449490\n",
       "K   403.428793          19  3.000000"
      ]
     },
     "execution_count": 146,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.transform({'Python':np.exp, 'Tensorflow':lambda x:x+10, 'Keras':np.sqrt})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "id": "62e7fd14",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>2980.957987</td>\n",
       "      <td>16</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>14</td>\n",
       "      <td>2.828427</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>1096.633158</td>\n",
       "      <td>10</td>\n",
       "      <td>1.414214</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>2.718282</td>\n",
       "      <td>19</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>8103.083928</td>\n",
       "      <td>19</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>1096.633158</td>\n",
       "      <td>13</td>\n",
       "      <td>1.732051</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>20.085537</td>\n",
       "      <td>12</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>20.085537</td>\n",
       "      <td>15</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>14</td>\n",
       "      <td>2.449490</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>403.428793</td>\n",
       "      <td>19</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Python  Tensorflow     Keras\n",
       "A  2980.957987          16  1.000000\n",
       "B     1.000000          14  2.828427\n",
       "C  1096.633158          10  1.414214\n",
       "D     2.718282          19  1.000000\n",
       "E  8103.083928          19       NaN\n",
       "F  1096.633158          13  1.732051\n",
       "H    20.085537          12  1.000000\n",
       "I    20.085537          15  1.000000\n",
       "J     1.000000          14  2.449490\n",
       "K   403.428793          19  3.000000"
      ]
     },
     "execution_count": 147,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.apply({'Python':np.exp,'Tensorflow':lambda x:x+10,'Keras':np.sqrt})"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1eb840d3",
   "metadata": {},
   "source": [
    "## 重排随机抽样"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "id": "23dad37c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>9</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>3</td>\n",
       "      <td>9</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>9</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A       9           1      5\n",
       "B       3           9      8\n",
       "C       4           1      7\n",
       "D       1           3      4\n",
       "E       1           6      9\n",
       "F       5           4      0\n",
       "H       9           6      5\n",
       "I       5           2      1\n",
       "J       7           9      2\n",
       "K       2           4      7"
      ]
     },
     "execution_count": 148,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "# 生成数据\n",
    "df = pd.DataFrame(data = np.random.randint(0,10,size = (10,3)),\n",
    "                  index = list('ABCDEFHIJK'),\n",
    "                  columns=['Python','Tensorflow','Keras'])\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "id": "90160dbd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>9</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>9</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>3</td>\n",
       "      <td>9</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "E       1           6      9\n",
       "J       7           9      2\n",
       "D       1           3      4\n",
       "K       2           4      7\n",
       "A       9           1      5\n",
       "H       9           6      5\n",
       "F       5           4      0\n",
       "I       5           2      1\n",
       "B       3           9      8\n",
       "C       4           1      7"
      ]
     },
     "execution_count": 149,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index = np.random.permutation(10) # 随机重排 -- 打乱原先的行顺序\n",
    "df.take(index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "id": "bbd22194",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>3</td>\n",
       "      <td>9</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>9</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "I       5           2      1\n",
       "B       3           9      8\n",
       "K       2           4      7\n",
       "A       9           1      5\n",
       "K       2           4      7"
      ]
     },
     "execution_count": 150,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 随机抽样 -- 抽取 5行\n",
    "index = np.random.randint(0,10,size = 5)\n",
    "df.take(index)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "161f5225",
   "metadata": {},
   "source": [
    "## 独热编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "id": "aff36c92",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>b</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>b</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>a</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>c</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>a</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>b</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key\n",
       "0   b\n",
       "1   b\n",
       "2   a\n",
       "3   c\n",
       "4   a\n",
       "5   b"
      ]
     },
     "execution_count": 151,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 哑变量，独热编码，1表示有，0表示没有\n",
    "\n",
    "# 准备数据\n",
    "df = pd.DataFrame({'key':['b','b','a','c','a','b']}) \n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "id": "25d08477",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   a  b  c\n",
       "0  0  1  0\n",
       "1  0  1  0\n",
       "2  1  0  0\n",
       "3  0  0  1\n",
       "4  1  0  0\n",
       "5  0  1  0"
      ]
     },
     "execution_count": 152,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.get_dummies(df,prefix='',prefix_sep='') # 哑变量，独热编码"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "48d18a67",
   "metadata": {},
   "source": [
    "# 数据重塑"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0ca496a7",
   "metadata": {},
   "source": [
    "## 转置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "id": "c014891b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>91</td>\n",
       "      <td>61</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>15</td>\n",
       "      <td>91</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>18</td>\n",
       "      <td>87</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>84</td>\n",
       "      <td>1</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>4</td>\n",
       "      <td>14</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>6</td>\n",
       "      <td>30</td>\n",
       "      <td>61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>69</td>\n",
       "      <td>91</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>4</td>\n",
       "      <td>68</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>45</td>\n",
       "      <td>27</td>\n",
       "      <td>94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>85</td>\n",
       "      <td>81</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A      91          61     89\n",
       "B      15          91     35\n",
       "C      18          87     40\n",
       "D      84           1     68\n",
       "E       4          14     32\n",
       "F       6          30     61\n",
       "H      69          91     12\n",
       "I       4          68     30\n",
       "J      45          27     94\n",
       "K      85          81     27"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "      <th>E</th>\n",
       "      <th>F</th>\n",
       "      <th>H</th>\n",
       "      <th>I</th>\n",
       "      <th>J</th>\n",
       "      <th>K</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Python</th>\n",
       "      <td>91</td>\n",
       "      <td>15</td>\n",
       "      <td>18</td>\n",
       "      <td>84</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>69</td>\n",
       "      <td>4</td>\n",
       "      <td>45</td>\n",
       "      <td>85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>61</td>\n",
       "      <td>91</td>\n",
       "      <td>87</td>\n",
       "      <td>1</td>\n",
       "      <td>14</td>\n",
       "      <td>30</td>\n",
       "      <td>91</td>\n",
       "      <td>68</td>\n",
       "      <td>27</td>\n",
       "      <td>81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>89</td>\n",
       "      <td>35</td>\n",
       "      <td>40</td>\n",
       "      <td>68</td>\n",
       "      <td>32</td>\n",
       "      <td>61</td>\n",
       "      <td>12</td>\n",
       "      <td>30</td>\n",
       "      <td>94</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             A   B   C   D   E   F   H   I   J   K\n",
       "Python      91  15  18  84   4   6  69   4  45  85\n",
       "Tensorflow  61  91  87   1  14  30  91  68  27  81\n",
       "Keras       89  35  40  68  32  61  12  30  94  27"
      ]
     },
     "execution_count": 153,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(data = np.random.randint(0,100,size = (10,3)), # 准备数据\n",
    "                  index = list('ABCDEFHIJK'), # 行标签\n",
    "                  columns=['Python','Tensorflow','Keras']) # 列标签\n",
    "display(df)\n",
    "df.T # 转置"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ea67ada6",
   "metadata": {},
   "source": [
    "## 多层索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "id": "2d0338cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">A</th>\n",
       "      <th>期中</th>\n",
       "      <td>29</td>\n",
       "      <td>78</td>\n",
       "      <td>64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>55</td>\n",
       "      <td>74</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">B</th>\n",
       "      <th>期中</th>\n",
       "      <td>19</td>\n",
       "      <td>23</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>82</td>\n",
       "      <td>84</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">C</th>\n",
       "      <th>期中</th>\n",
       "      <td>75</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>13</td>\n",
       "      <td>46</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">D</th>\n",
       "      <th>期中</th>\n",
       "      <td>47</td>\n",
       "      <td>50</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>12</td>\n",
       "      <td>56</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">E</th>\n",
       "      <th>期中</th>\n",
       "      <td>84</td>\n",
       "      <td>48</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>40</td>\n",
       "      <td>57</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">F</th>\n",
       "      <th>期中</th>\n",
       "      <td>55</td>\n",
       "      <td>87</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>13</td>\n",
       "      <td>32</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">H</th>\n",
       "      <th>期中</th>\n",
       "      <td>44</td>\n",
       "      <td>7</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>20</td>\n",
       "      <td>86</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">I</th>\n",
       "      <th>期中</th>\n",
       "      <td>71</td>\n",
       "      <td>68</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>99</td>\n",
       "      <td>38</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">J</th>\n",
       "      <th>期中</th>\n",
       "      <td>25</td>\n",
       "      <td>57</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>31</td>\n",
       "      <td>89</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">K</th>\n",
       "      <th>期中</th>\n",
       "      <td>43</td>\n",
       "      <td>87</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>98</td>\n",
       "      <td>17</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Python  Tensorflow  Keras\n",
       "A 期中      29          78     64\n",
       "  期末      55          74     58\n",
       "B 期中      19          23     22\n",
       "  期末      82          84     55\n",
       "C 期中      75           2      3\n",
       "  期末      13          46     90\n",
       "D 期中      47          50     49\n",
       "  期末      12          56      7\n",
       "E 期中      84          48     47\n",
       "  期末      40          57      8\n",
       "F 期中      55          87     24\n",
       "  期末      13          32     44\n",
       "H 期中      44           7     74\n",
       "  期末      20          86     46\n",
       "I 期中      71          68     55\n",
       "  期末      99          38     35\n",
       "J 期中      25          57     32\n",
       "  期末      31          89     28\n",
       "K 期中      43          87     75\n",
       "  期末      98          17     89"
      ]
     },
     "execution_count": 154,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = pd.DataFrame(data = np.random.randint(0,100,size = (20,3)),\n",
    "                   index = pd.MultiIndex.from_product([list('ABCDEFHIJK'),['期中','期末']]), # 多层索引\n",
    "                   columns=['Python','Tensorflow','Keras'])\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "id": "34161c88",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th colspan=\"2\" halign=\"left\">Python</th>\n",
       "      <th colspan=\"2\" halign=\"left\">Tensorflow</th>\n",
       "      <th colspan=\"2\" halign=\"left\">Keras</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th>期中</th>\n",
       "      <th>期末</th>\n",
       "      <th>期中</th>\n",
       "      <th>期末</th>\n",
       "      <th>期中</th>\n",
       "      <th>期末</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>29</td>\n",
       "      <td>55</td>\n",
       "      <td>78</td>\n",
       "      <td>74</td>\n",
       "      <td>64</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>19</td>\n",
       "      <td>82</td>\n",
       "      <td>23</td>\n",
       "      <td>84</td>\n",
       "      <td>22</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>75</td>\n",
       "      <td>13</td>\n",
       "      <td>2</td>\n",
       "      <td>46</td>\n",
       "      <td>3</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>47</td>\n",
       "      <td>12</td>\n",
       "      <td>50</td>\n",
       "      <td>56</td>\n",
       "      <td>49</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>84</td>\n",
       "      <td>40</td>\n",
       "      <td>48</td>\n",
       "      <td>57</td>\n",
       "      <td>47</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>55</td>\n",
       "      <td>13</td>\n",
       "      <td>87</td>\n",
       "      <td>32</td>\n",
       "      <td>24</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>44</td>\n",
       "      <td>20</td>\n",
       "      <td>7</td>\n",
       "      <td>86</td>\n",
       "      <td>74</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>71</td>\n",
       "      <td>99</td>\n",
       "      <td>68</td>\n",
       "      <td>38</td>\n",
       "      <td>55</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>25</td>\n",
       "      <td>31</td>\n",
       "      <td>57</td>\n",
       "      <td>89</td>\n",
       "      <td>32</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>43</td>\n",
       "      <td>98</td>\n",
       "      <td>87</td>\n",
       "      <td>17</td>\n",
       "      <td>75</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Python     Tensorflow     Keras    \n",
       "      期中  期末         期中  期末    期中  期末\n",
       "A     29  55         78  74    64  58\n",
       "B     19  82         23  84    22  55\n",
       "C     75  13          2  46     3  90\n",
       "D     47  12         50  56    49   7\n",
       "E     84  40         48  57    47   8\n",
       "F     55  13         87  32    24  44\n",
       "H     44  20          7  86    74  46\n",
       "I     71  99         68  38    55  35\n",
       "J     25  31         57  89    32  28\n",
       "K     43  98         87  17    75  89"
      ]
     },
     "execution_count": 156,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.unstack(level = -1) # 行旋转成列，level指定哪一层，进行变换"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "id": "2f650a19",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>期中</th>\n",
       "      <th>期末</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">A</th>\n",
       "      <th>Python</th>\n",
       "      <td>29</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>78</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>64</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">B</th>\n",
       "      <th>Python</th>\n",
       "      <td>19</td>\n",
       "      <td>82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>23</td>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>22</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">C</th>\n",
       "      <th>Python</th>\n",
       "      <td>75</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>2</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>3</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">D</th>\n",
       "      <th>Python</th>\n",
       "      <td>47</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>50</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>49</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">E</th>\n",
       "      <th>Python</th>\n",
       "      <td>84</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>48</td>\n",
       "      <td>57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>47</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">F</th>\n",
       "      <th>Python</th>\n",
       "      <td>55</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>87</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>24</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">H</th>\n",
       "      <th>Python</th>\n",
       "      <td>44</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>7</td>\n",
       "      <td>86</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>74</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">I</th>\n",
       "      <th>Python</th>\n",
       "      <td>71</td>\n",
       "      <td>99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>68</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>55</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">J</th>\n",
       "      <th>Python</th>\n",
       "      <td>25</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>57</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>32</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">K</th>\n",
       "      <th>Python</th>\n",
       "      <td>43</td>\n",
       "      <td>98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>87</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>75</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              期中  期末\n",
       "A Python      29  55\n",
       "  Tensorflow  78  74\n",
       "  Keras       64  58\n",
       "B Python      19  82\n",
       "  Tensorflow  23  84\n",
       "  Keras       22  55\n",
       "C Python      75  13\n",
       "  Tensorflow   2  46\n",
       "  Keras        3  90\n",
       "D Python      47  12\n",
       "  Tensorflow  50  56\n",
       "  Keras       49   7\n",
       "E Python      84  40\n",
       "  Tensorflow  48  57\n",
       "  Keras       47   8\n",
       "F Python      55  13\n",
       "  Tensorflow  87  32\n",
       "  Keras       24  44\n",
       "H Python      44  20\n",
       "  Tensorflow   7  86\n",
       "  Keras       74  46\n",
       "I Python      71  99\n",
       "  Tensorflow  68  38\n",
       "  Keras       55  35\n",
       "J Python      25  31\n",
       "  Tensorflow  57  89\n",
       "  Keras       32  28\n",
       "K Python      43  98\n",
       "  Tensorflow  87  17\n",
       "  Keras       75  89"
      ]
     },
     "execution_count": 158,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.stack().unstack(level = 1) # 行列互换"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "id": "963644aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th colspan=\"2\" halign=\"left\">Python</th>\n",
       "      <th colspan=\"2\" halign=\"left\">Math</th>\n",
       "      <th colspan=\"2\" halign=\"left\">En</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th>期中</th>\n",
       "      <th>期末</th>\n",
       "      <th>期中</th>\n",
       "      <th>期末</th>\n",
       "      <th>期中</th>\n",
       "      <th>期末</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>77</td>\n",
       "      <td>41</td>\n",
       "      <td>60</td>\n",
       "      <td>87</td>\n",
       "      <td>97</td>\n",
       "      <td>97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>91</td>\n",
       "      <td>68</td>\n",
       "      <td>43</td>\n",
       "      <td>88</td>\n",
       "      <td>17</td>\n",
       "      <td>59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>37</td>\n",
       "      <td>60</td>\n",
       "      <td>70</td>\n",
       "      <td>9</td>\n",
       "      <td>46</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>64</td>\n",
       "      <td>29</td>\n",
       "      <td>13</td>\n",
       "      <td>11</td>\n",
       "      <td>81</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>36</td>\n",
       "      <td>21</td>\n",
       "      <td>87</td>\n",
       "      <td>44</td>\n",
       "      <td>78</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>68</td>\n",
       "      <td>38</td>\n",
       "      <td>59</td>\n",
       "      <td>8</td>\n",
       "      <td>80</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>52</td>\n",
       "      <td>27</td>\n",
       "      <td>13</td>\n",
       "      <td>71</td>\n",
       "      <td>82</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>46</td>\n",
       "      <td>32</td>\n",
       "      <td>4</td>\n",
       "      <td>63</td>\n",
       "      <td>80</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>83</td>\n",
       "      <td>90</td>\n",
       "      <td>79</td>\n",
       "      <td>33</td>\n",
       "      <td>40</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>76</td>\n",
       "      <td>44</td>\n",
       "      <td>47</td>\n",
       "      <td>89</td>\n",
       "      <td>81</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Python     Math      En    \n",
       "      期中  期末   期中  期末  期中  期末\n",
       "A     77  41   60  87  97  97\n",
       "B     91  68   43  88  17  59\n",
       "C     37  60   70   9  46  55\n",
       "D     64  29   13  11  81  22\n",
       "E     36  21   87  44  78   8\n",
       "F     68  38   59   8  80  16\n",
       "H     52  27   13  71  82  26\n",
       "I     46  32    4  63  80  34\n",
       "J     83  90   79  33  40  68\n",
       "K     76  44   47  89  81  11"
      ]
     },
     "execution_count": 155,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df3 = pd.DataFrame(data = np.random.randint(0,100,size = (10,6)),\n",
    "                   index = list('ABCDEFHIJK'),\n",
    "                   columns=pd.MultiIndex.from_product([['Python','Math','En'],['期中','期末']]))\n",
    "df3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 157,
   "id": "96318504",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>En</th>\n",
       "      <th>Math</th>\n",
       "      <th>Python</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">A</th>\n",
       "      <th>期中</th>\n",
       "      <td>97</td>\n",
       "      <td>60</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>97</td>\n",
       "      <td>87</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">B</th>\n",
       "      <th>期中</th>\n",
       "      <td>17</td>\n",
       "      <td>43</td>\n",
       "      <td>91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>59</td>\n",
       "      <td>88</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">C</th>\n",
       "      <th>期中</th>\n",
       "      <td>46</td>\n",
       "      <td>70</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>55</td>\n",
       "      <td>9</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">D</th>\n",
       "      <th>期中</th>\n",
       "      <td>81</td>\n",
       "      <td>13</td>\n",
       "      <td>64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>22</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">E</th>\n",
       "      <th>期中</th>\n",
       "      <td>78</td>\n",
       "      <td>87</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>8</td>\n",
       "      <td>44</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">F</th>\n",
       "      <th>期中</th>\n",
       "      <td>80</td>\n",
       "      <td>59</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>16</td>\n",
       "      <td>8</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">H</th>\n",
       "      <th>期中</th>\n",
       "      <td>82</td>\n",
       "      <td>13</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>26</td>\n",
       "      <td>71</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">I</th>\n",
       "      <th>期中</th>\n",
       "      <td>80</td>\n",
       "      <td>4</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>34</td>\n",
       "      <td>63</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">J</th>\n",
       "      <th>期中</th>\n",
       "      <td>40</td>\n",
       "      <td>79</td>\n",
       "      <td>83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>68</td>\n",
       "      <td>33</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">K</th>\n",
       "      <th>期中</th>\n",
       "      <td>81</td>\n",
       "      <td>47</td>\n",
       "      <td>76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>11</td>\n",
       "      <td>89</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      En  Math  Python\n",
       "A 期中  97    60      77\n",
       "  期末  97    87      41\n",
       "B 期中  17    43      91\n",
       "  期末  59    88      68\n",
       "C 期中  46    70      37\n",
       "  期末  55     9      60\n",
       "D 期中  81    13      64\n",
       "  期末  22    11      29\n",
       "E 期中  78    87      36\n",
       "  期末   8    44      21\n",
       "F 期中  80    59      68\n",
       "  期末  16     8      38\n",
       "H 期中  82    13      52\n",
       "  期末  26    71      27\n",
       "I 期中  80     4      46\n",
       "  期末  34    63      32\n",
       "J 期中  40    79      83\n",
       "  期末  68    33      90\n",
       "K 期中  81    47      76\n",
       "  期末  11    89      44"
      ]
     },
     "execution_count": 157,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df3.stack(level = 1) # 列旋转成行"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "23173a56",
   "metadata": {},
   "source": [
    "## 多层索引运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "id": "0d771a9e",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/0q/2y7xgmvn00b1090yx3d_n1140000gn/T/ipykernel_58118/2717870846.py:3: FutureWarning: Using the level keyword in DataFrame and Series aggregations is deprecated and will be removed in a future version. Use groupby instead. df.sum(level=1) should use df.groupby(level=1).sum().\n",
      "  df2.sum(level = 0)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>84</td>\n",
       "      <td>152</td>\n",
       "      <td>122</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>101</td>\n",
       "      <td>107</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>88</td>\n",
       "      <td>48</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>59</td>\n",
       "      <td>106</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>124</td>\n",
       "      <td>105</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>68</td>\n",
       "      <td>119</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>64</td>\n",
       "      <td>93</td>\n",
       "      <td>120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>170</td>\n",
       "      <td>106</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>56</td>\n",
       "      <td>146</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>141</td>\n",
       "      <td>104</td>\n",
       "      <td>164</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A      84         152    122\n",
       "B     101         107     77\n",
       "C      88          48     93\n",
       "D      59         106     56\n",
       "E     124         105     55\n",
       "F      68         119     68\n",
       "H      64          93    120\n",
       "I     170         106     90\n",
       "J      56         146     60\n",
       "K     141         104    164"
      ]
     },
     "execution_count": 159,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 期中、期末消失\n",
    "# 每个人，期中期末总分数\n",
    "df2.sum(level = 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 160,
   "id": "318df4d9",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/0q/2y7xgmvn00b1090yx3d_n1140000gn/T/ipykernel_58118/4153577136.py:3: FutureWarning: Using the level keyword in DataFrame and Series aggregations is deprecated and will be removed in a future version. Use groupby instead. df.median(level=1) should use df.groupby(level=1).median().\n",
      "  df2.mean(level = 1)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>期中</th>\n",
       "      <td>49.2</td>\n",
       "      <td>50.7</td>\n",
       "      <td>44.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>46.3</td>\n",
       "      <td>57.9</td>\n",
       "      <td>46.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python  Tensorflow  Keras\n",
       "期中    49.2        50.7   44.5\n",
       "期末    46.3        57.9   46.0"
      ]
     },
     "execution_count": 160,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 同学索引消失\n",
    "# 所有同学，期中、期末平均分\n",
    "df2.mean(level = 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "id": "6e969adb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th colspan=\"2\" halign=\"left\">Python</th>\n",
       "      <th colspan=\"2\" halign=\"left\">Math</th>\n",
       "      <th colspan=\"2\" halign=\"left\">En</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th>期中</th>\n",
       "      <th>期末</th>\n",
       "      <th>期中</th>\n",
       "      <th>期末</th>\n",
       "      <th>期中</th>\n",
       "      <th>期末</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>77</td>\n",
       "      <td>41</td>\n",
       "      <td>60</td>\n",
       "      <td>87</td>\n",
       "      <td>97</td>\n",
       "      <td>97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>91</td>\n",
       "      <td>68</td>\n",
       "      <td>43</td>\n",
       "      <td>88</td>\n",
       "      <td>17</td>\n",
       "      <td>59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>37</td>\n",
       "      <td>60</td>\n",
       "      <td>70</td>\n",
       "      <td>9</td>\n",
       "      <td>46</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>64</td>\n",
       "      <td>29</td>\n",
       "      <td>13</td>\n",
       "      <td>11</td>\n",
       "      <td>81</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>36</td>\n",
       "      <td>21</td>\n",
       "      <td>87</td>\n",
       "      <td>44</td>\n",
       "      <td>78</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>68</td>\n",
       "      <td>38</td>\n",
       "      <td>59</td>\n",
       "      <td>8</td>\n",
       "      <td>80</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>52</td>\n",
       "      <td>27</td>\n",
       "      <td>13</td>\n",
       "      <td>71</td>\n",
       "      <td>82</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>46</td>\n",
       "      <td>32</td>\n",
       "      <td>4</td>\n",
       "      <td>63</td>\n",
       "      <td>80</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>83</td>\n",
       "      <td>90</td>\n",
       "      <td>79</td>\n",
       "      <td>33</td>\n",
       "      <td>40</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>76</td>\n",
       "      <td>44</td>\n",
       "      <td>47</td>\n",
       "      <td>89</td>\n",
       "      <td>81</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Python     Math      En    \n",
       "      期中  期末   期中  期末  期中  期末\n",
       "A     77  41   60  87  97  97\n",
       "B     91  68   43  88  17  59\n",
       "C     37  60   70   9  46  55\n",
       "D     64  29   13  11  81  22\n",
       "E     36  21   87  44  78   8\n",
       "F     68  38   59   8  80  16\n",
       "H     52  27   13  71  82  26\n",
       "I     46  32    4  63  80  34\n",
       "J     83  90   79  33  40  68\n",
       "K     76  44   47  89  81  11"
      ]
     },
     "execution_count": 163,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "id": "497af16e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "77"
      ]
     },
     "execution_count": 161,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# df3是多层列索引，可以直接使用[],根据层级关系取数据\n",
    "df3['Python','期中']['A']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "id": "63cebc22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">A</th>\n",
       "      <th>期中</th>\n",
       "      <td>29</td>\n",
       "      <td>78</td>\n",
       "      <td>64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>55</td>\n",
       "      <td>74</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">B</th>\n",
       "      <th>期中</th>\n",
       "      <td>19</td>\n",
       "      <td>23</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>82</td>\n",
       "      <td>84</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">C</th>\n",
       "      <th>期中</th>\n",
       "      <td>75</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>13</td>\n",
       "      <td>46</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">D</th>\n",
       "      <th>期中</th>\n",
       "      <td>47</td>\n",
       "      <td>50</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>12</td>\n",
       "      <td>56</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">E</th>\n",
       "      <th>期中</th>\n",
       "      <td>84</td>\n",
       "      <td>48</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>40</td>\n",
       "      <td>57</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">F</th>\n",
       "      <th>期中</th>\n",
       "      <td>55</td>\n",
       "      <td>87</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>13</td>\n",
       "      <td>32</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">H</th>\n",
       "      <th>期中</th>\n",
       "      <td>44</td>\n",
       "      <td>7</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>20</td>\n",
       "      <td>86</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">I</th>\n",
       "      <th>期中</th>\n",
       "      <td>71</td>\n",
       "      <td>68</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>99</td>\n",
       "      <td>38</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">J</th>\n",
       "      <th>期中</th>\n",
       "      <td>25</td>\n",
       "      <td>57</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>31</td>\n",
       "      <td>89</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">K</th>\n",
       "      <th>期中</th>\n",
       "      <td>43</td>\n",
       "      <td>87</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>期末</th>\n",
       "      <td>98</td>\n",
       "      <td>17</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Python  Tensorflow  Keras\n",
       "A 期中      29          78     64\n",
       "  期末      55          74     58\n",
       "B 期中      19          23     22\n",
       "  期末      82          84     55\n",
       "C 期中      75           2      3\n",
       "  期末      13          46     90\n",
       "D 期中      47          50     49\n",
       "  期末      12          56      7\n",
       "E 期中      84          48     47\n",
       "  期末      40          57      8\n",
       "F 期中      55          87     24\n",
       "  期末      13          32     44\n",
       "H 期中      44           7     74\n",
       "  期末      20          86     46\n",
       "I 期中      71          68     55\n",
       "  期末      99          38     35\n",
       "J 期中      25          57     32\n",
       "  期末      31          89     28\n",
       "K 期中      43          87     75\n",
       "  期末      98          17     89"
      ]
     },
     "execution_count": 164,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "id": "71242a21",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "('Python', '期中')",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py:3621\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m   3620\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 3621\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_engine\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcasted_key\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   3622\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/_libs/index.pyx:136\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/_libs/index.pyx:163\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5198\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5206\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
      "\u001b[0;31mKeyError\u001b[0m: ('Python', '期中')",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "Input \u001b[0;32mIn [162]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[38;5;66;03m# df2不是多层列索引，不能直接使用[],根据层级关系取数据\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mdf2\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mPython\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m期中\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/frame.py:3505\u001b[0m, in \u001b[0;36mDataFrame.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m   3503\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcolumns\u001b[38;5;241m.\u001b[39mnlevels \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[1;32m   3504\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_getitem_multilevel(key)\n\u001b[0;32m-> 3505\u001b[0m indexer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcolumns\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   3506\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m is_integer(indexer):\n\u001b[1;32m   3507\u001b[0m     indexer \u001b[38;5;241m=\u001b[39m [indexer]\n",
      "File \u001b[0;32m~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py:3623\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m   3621\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_engine\u001b[38;5;241m.\u001b[39mget_loc(casted_key)\n\u001b[1;32m   3622\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[0;32m-> 3623\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01merr\u001b[39;00m\n\u001b[1;32m   3624\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n\u001b[1;32m   3625\u001b[0m     \u001b[38;5;66;03m# If we have a listlike key, _check_indexing_error will raise\u001b[39;00m\n\u001b[1;32m   3626\u001b[0m     \u001b[38;5;66;03m#  InvalidIndexError. Otherwise we fall through and re-raise\u001b[39;00m\n\u001b[1;32m   3627\u001b[0m     \u001b[38;5;66;03m#  the TypeError.\u001b[39;00m\n\u001b[1;32m   3628\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_check_indexing_error(key)\n",
      "\u001b[0;31mKeyError\u001b[0m: ('Python', '期中')"
     ]
    }
   ],
   "source": [
    "# df2不是多层列索引，不能直接使用[],根据层级关系取数据\n",
    "df2['Python','期中']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2845ef4e",
   "metadata": {},
   "source": [
    "# 数学和统计方法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "df2daf97",
   "metadata": {},
   "source": [
    "## 简单统计指标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "id": "6b3019f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>47.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>44.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>44.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>57.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>NaN</td>\n",
       "      <td>9.0</td>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>22.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>52.0</td>\n",
       "      <td>42.0</td>\n",
       "      <td>78.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>48.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>46.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>59.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>NaN</td>\n",
       "      <td>73.0</td>\n",
       "      <td>46.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>NaN</td>\n",
       "      <td>50.0</td>\n",
       "      <td>14.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>75.0</td>\n",
       "      <td>26.0</td>\n",
       "      <td>45.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>L</th>\n",
       "      <td>68.0</td>\n",
       "      <td>28.0</td>\n",
       "      <td>73.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>NaN</td>\n",
       "      <td>52.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>N</th>\n",
       "      <td>26.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>O</th>\n",
       "      <td>63.0</td>\n",
       "      <td>79.0</td>\n",
       "      <td>79.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>P</th>\n",
       "      <td>9.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>71.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q</th>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>63.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>R</th>\n",
       "      <td>75.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>19.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S</th>\n",
       "      <td>22.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>8.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>24.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>U</th>\n",
       "      <td>19.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>30.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A    47.0         NaN   44.0\n",
       "B    44.0         8.0   57.0\n",
       "C     NaN         9.0   15.0\n",
       "D     NaN         NaN   22.0\n",
       "E    52.0        42.0   78.0\n",
       "F    48.0         NaN   46.0\n",
       "H     NaN         NaN   59.0\n",
       "I     NaN        73.0   46.0\n",
       "J     NaN        50.0   14.0\n",
       "K    75.0        26.0   45.0\n",
       "L    68.0        28.0   73.0\n",
       "M     NaN        52.0    NaN\n",
       "N    26.0         NaN    NaN\n",
       "O    63.0        79.0   79.0\n",
       "P     9.0         NaN   71.0\n",
       "Q    12.0         1.0   63.0\n",
       "R    75.0         NaN   19.0\n",
       "S    22.0         NaN    6.0\n",
       "T     8.0         NaN   24.0\n",
       "U    19.0        12.0   30.0"
      ]
     },
     "execution_count": 165,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(data = np.random.randint(0,100,size = (20,3)),\n",
    "                  index = list('ABCDEFHIJKLMNOPQRSTU'), # 行标签\n",
    "                  columns=['Python','Tensorflow','Keras']) # 列标签\n",
    "\n",
    "# 数据转换\n",
    "def convert(x):\n",
    "    if x > 80:\n",
    "        return np.NaN\n",
    "    else:\n",
    "        return x\n",
    "df['Python'] = df['Python'].map(convert)\n",
    "\n",
    "df['Tensorflow'] = df['Tensorflow'].apply(convert)\n",
    "\n",
    "df['Keras'] = df['Keras'].transform(convert)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "id": "1829ed58",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Python        14\n",
       "Tensorflow    11\n",
       "Keras         18\n",
       "dtype: int64"
      ]
     },
     "execution_count": 166,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.count() # 统计非空数据的个数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "id": "5e79e471",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>0</td>\n",
       "      <td>56</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>56</td>\n",
       "      <td>12</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>86</td>\n",
       "      <td>50</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>5</td>\n",
       "      <td>68</td>\n",
       "      <td>72</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>67</td>\n",
       "      <td>33</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>6</td>\n",
       "      <td>11</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>29</td>\n",
       "      <td>66</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>47</td>\n",
       "      <td>24</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>34</td>\n",
       "      <td>37</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>94</td>\n",
       "      <td>62</td>\n",
       "      <td>78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>L</th>\n",
       "      <td>24</td>\n",
       "      <td>36</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>54</td>\n",
       "      <td>42</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>N</th>\n",
       "      <td>36</td>\n",
       "      <td>5</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>O</th>\n",
       "      <td>35</td>\n",
       "      <td>75</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>P</th>\n",
       "      <td>48</td>\n",
       "      <td>54</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q</th>\n",
       "      <td>82</td>\n",
       "      <td>7</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>R</th>\n",
       "      <td>85</td>\n",
       "      <td>25</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S</th>\n",
       "      <td>68</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>20</td>\n",
       "      <td>91</td>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>U</th>\n",
       "      <td>17</td>\n",
       "      <td>59</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A       0          56      5\n",
       "B      56          12     93\n",
       "C      86          50     27\n",
       "D       5          68     72\n",
       "E      67          33     30\n",
       "F       6          11      5\n",
       "H      29          66      9\n",
       "I      47          24     33\n",
       "J      34          37     50\n",
       "K      94          62     78\n",
       "L      24          36     58\n",
       "M      54          42     56\n",
       "N      36           5     60\n",
       "O      35          75     12\n",
       "P      48          54     12\n",
       "Q      82           7     26\n",
       "R      85          25     33\n",
       "S      68           2      5\n",
       "T      20          91     53\n",
       "U      17          59     42"
      ]
     },
     "execution_count": 167,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(data = np.random.randint(0,100,size = (20,3)),\n",
    "                  index = list('ABCDEFHIJKLMNOPQRSTU'),\n",
    "                  columns=['Python','Tensorflow','Keras'])\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "id": "4d3a039c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Python        41.5\n",
       "Tensorflow    39.5\n",
       "Keras         33.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 168,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.median() # 中位数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "id": "81ba262e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Python        94\n",
       "Tensorflow    91\n",
       "Keras         93\n",
       "dtype: int64"
      ]
     },
     "execution_count": 169,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.max() # 最大值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "id": "92c71d2d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0.25</th>\n",
       "      <td>23.00</td>\n",
       "      <td>21.00</td>\n",
       "      <td>12.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0.50</th>\n",
       "      <td>41.50</td>\n",
       "      <td>39.50</td>\n",
       "      <td>33.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0.75</th>\n",
       "      <td>67.25</td>\n",
       "      <td>59.75</td>\n",
       "      <td>56.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Python  Tensorflow  Keras\n",
       "0.25   23.00       21.00   12.0\n",
       "0.50   41.50       39.50   33.0\n",
       "0.75   67.25       59.75   56.5"
      ]
     },
     "execution_count": 170,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.quantile(q = [0.25, 0.5, 0.75]) # 分位数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "397688a6",
   "metadata": {},
   "source": [
    "## 索引标签、位置获取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 171,
   "id": "913a5c66",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "17"
      ]
     },
     "execution_count": 171,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Tensorflow'].argmin() # 计算最小值的位置,自然数 0、1、2..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "id": "f0cacfe9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 172,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Keras'].argmax() # 找出最大值的位置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "id": "9c7218b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Python        K\n",
       "Tensorflow    T\n",
       "Keras         B\n",
       "dtype: object"
      ]
     },
     "execution_count": 173,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.idxmax() # 最大值的索引标签：index标记"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "id": "fae3af2e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Python        A\n",
       "Tensorflow    S\n",
       "Keras         A\n",
       "dtype: object"
      ]
     },
     "execution_count": 174,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.idxmin() # 最小值索引标签"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "id": "db3c9f7c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "29"
      ]
     },
     "execution_count": 175,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 找到 特定同学的分数\n",
    "df['Python'].loc['H']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "id": "3b0afa20",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "27"
      ]
     },
     "execution_count": 176,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Keras'].loc['C']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "32e0743f",
   "metadata": {},
   "source": [
    "## 更多统计指标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 178,
   "id": "1f322acb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>L</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>N</th>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>O</th>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>P</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>R</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>U</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A       1           3      0\n",
       "B       0           2      4\n",
       "C       3           0      3\n",
       "D       3           1      2\n",
       "E       1           1      2\n",
       "F       4           0      1\n",
       "H       0           2      2\n",
       "I       2           0      0\n",
       "J       4           1      0\n",
       "K       0           3      0\n",
       "L       3           3      2\n",
       "M       3           0      1\n",
       "N       4           2      4\n",
       "O       1           4      3\n",
       "P       4           1      2\n",
       "Q       0           2      3\n",
       "R       3           0      4\n",
       "S       0           2      3\n",
       "T       2           2      2\n",
       "U       2           2      0"
      ]
     },
     "execution_count": 178,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(data = np.random.randint(0, 5, size = (20,3)), # 数据\n",
    "                  index = list('ABCDEFHIJKLMNOPQRSTU'), # 行索引\n",
    "                  columns=['Python','Tensorflow','Keras']) # 列索引\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "id": "9ebbd1aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    5\n",
       "3    5\n",
       "4    4\n",
       "1    3\n",
       "2    3\n",
       "Name: Python, dtype: int64"
      ]
     },
     "execution_count": 179,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Python'].value_counts() # 统计元素出现次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 180,
   "id": "10b9eac8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 0, 3, 4, 2])"
      ]
     },
     "execution_count": 180,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Python'].unique() # 去重"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 181,
   "id": "c8776b6f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>L</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>N</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>O</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>P</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>R</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>U</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A       1           3      0\n",
       "B       0           2      0\n",
       "C       0           0      0\n",
       "D       0           0      0\n",
       "E       0           0      0\n",
       "F       0           0      0\n",
       "H       0           0      0\n",
       "I       0           0      0\n",
       "J       0           0      0\n",
       "K       0           0      0\n",
       "L       0           0      0\n",
       "M       0           0      0\n",
       "N       0           0      0\n",
       "O       0           0      0\n",
       "P       0           0      0\n",
       "Q       0           0      0\n",
       "R       0           0      0\n",
       "S       0           0      0\n",
       "T       0           0      0\n",
       "U       0           0      0"
      ]
     },
     "execution_count": 181,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.cummin() # 累计最小值：一个列中，从开始到当前位置的 最小值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 182,
   "id": "3958f4bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>3.0</td>\n",
       "      <td>-2.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>-2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>3.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H</th>\n",
       "      <td>-4.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>2.0</td>\n",
       "      <td>-2.0</td>\n",
       "      <td>-2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>J</th>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K</th>\n",
       "      <td>-4.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>L</th>\n",
       "      <td>3.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>0.0</td>\n",
       "      <td>-3.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>N</th>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>O</th>\n",
       "      <td>-3.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>P</th>\n",
       "      <td>3.0</td>\n",
       "      <td>-3.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q</th>\n",
       "      <td>-4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>R</th>\n",
       "      <td>3.0</td>\n",
       "      <td>-2.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>S</th>\n",
       "      <td>-3.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>U</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-2.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Tensorflow  Keras\n",
       "A     NaN         NaN    NaN\n",
       "B    -1.0        -1.0    4.0\n",
       "C     3.0        -2.0   -1.0\n",
       "D     0.0         1.0   -1.0\n",
       "E    -2.0         0.0    0.0\n",
       "F     3.0        -1.0   -1.0\n",
       "H    -4.0         2.0    1.0\n",
       "I     2.0        -2.0   -2.0\n",
       "J     2.0         1.0    0.0\n",
       "K    -4.0         2.0    0.0\n",
       "L     3.0         0.0    2.0\n",
       "M     0.0        -3.0   -1.0\n",
       "N     1.0         2.0    3.0\n",
       "O    -3.0         2.0   -1.0\n",
       "P     3.0        -3.0   -1.0\n",
       "Q    -4.0         1.0    1.0\n",
       "R     3.0        -2.0    1.0\n",
       "S    -3.0         2.0   -1.0\n",
       "T     2.0         0.0   -1.0\n",
       "U     0.0         0.0   -2.0"
      ]
     },
     "execution_count": 182,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.diff() # 计算差分，和上一行，相减"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bf61137d",
   "metadata": {},
   "source": [
    "## 高级统计指标"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f633a626",
   "metadata": {},
   "source": [
    "\n",
    "![](2_Pandas数据分析库_images/3.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 183,
   "id": "d4aa295b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Python</th>\n",
       "      <td>2.315789</td>\n",
       "      <td>-0.947368</td>\n",
       "      <td>-0.157895</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>-0.947368</td>\n",
       "      <td>1.418421</td>\n",
       "      <td>0.057895</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>-0.157895</td>\n",
       "      <td>0.057895</td>\n",
       "      <td>1.989474</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              Python  Tensorflow     Keras\n",
       "Python      2.315789   -0.947368 -0.157895\n",
       "Tensorflow -0.947368    1.418421  0.057895\n",
       "Keras      -0.157895    0.057895  1.989474"
      ]
     },
     "execution_count": 183,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.cov() # 属性的协方差"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 184,
   "id": "ee7ae1fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.15789473684210525"
      ]
     },
     "execution_count": 184,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Python'].cov(df['Keras']) # Python 和 Keras的协方差"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 185,
   "id": "c5d2bdef",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Python</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.522717</td>\n",
       "      <td>-0.073561</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tensorflow</th>\n",
       "      <td>-0.522717</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.034464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Keras</th>\n",
       "      <td>-0.073561</td>\n",
       "      <td>0.034464</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              Python  Tensorflow     Keras\n",
       "Python      1.000000   -0.522717 -0.073561\n",
       "Tensorflow -0.522717    1.000000  0.034464\n",
       "Keras      -0.073561    0.034464  1.000000"
      ]
     },
     "execution_count": 185,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.corr() # 所有属性相关性系数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 186,
   "id": "3c394ca8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Python       -0.522717\n",
       "Tensorflow    1.000000\n",
       "Keras         0.034464\n",
       "dtype: float64"
      ]
     },
     "execution_count": 186,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.corrwith(df['Tensorflow']) # 单一属性相关性系数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d88c1a9a",
   "metadata": {},
   "source": [
    "# 数据排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 187,
   "id": "16b491ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Pytorch</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>q</th>\n",
       "      <td>18</td>\n",
       "      <td>1</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>w</th>\n",
       "      <td>12</td>\n",
       "      <td>22</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>9</td>\n",
       "      <td>14</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>19</td>\n",
       "      <td>23</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>t</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>y</th>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>u</th>\n",
       "      <td>29</td>\n",
       "      <td>5</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>9</td>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>o</th>\n",
       "      <td>28</td>\n",
       "      <td>8</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>19</td>\n",
       "      <td>3</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>22</td>\n",
       "      <td>15</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>6</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>0</td>\n",
       "      <td>13</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>21</td>\n",
       "      <td>6</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>19</td>\n",
       "      <td>21</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>s</th>\n",
       "      <td>13</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>11</td>\n",
       "      <td>13</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>v</th>\n",
       "      <td>29</td>\n",
       "      <td>29</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>28</td>\n",
       "      <td>4</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>n</th>\n",
       "      <td>29</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>10</td>\n",
       "      <td>24</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>22</td>\n",
       "      <td>14</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>26</td>\n",
       "      <td>12</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>6</td>\n",
       "      <td>13</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>20</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Pytorch\n",
       "q      18      1       16\n",
       "w      12     22       27\n",
       "e       9     14       29\n",
       "r      19     23        9\n",
       "t      12     13       10\n",
       "y       5      5        6\n",
       "u      29      5       21\n",
       "i       9     17        1\n",
       "o      28      8       26\n",
       "i      19      3       29\n",
       "j      22     15        1\n",
       "h       6     20       28\n",
       "g      17      1       14\n",
       "f       0     13       21\n",
       "c      21      6       22\n",
       "a      19     21        2\n",
       "s      13      8        3\n",
       "d       4      1       12\n",
       "c      11     13        1\n",
       "v      29     29       25\n",
       "b      28      4       16\n",
       "n      29      6        3\n",
       "e       7      9       10\n",
       "r       4      1        9\n",
       "f      10     24        6\n",
       "g      22     14       11\n",
       "h      28     23       11\n",
       "j      26     12       11\n",
       "c       6     13        7\n",
       "f      20      9       10"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(data = np.random.randint(0,30,size = (30,3)), # 数据\n",
    "                  index = list('qwertyuioijhgfcasdcvbnerfghjcf'), # 行标签\n",
    "                  columns = ['Python','Keras','Pytorch']) # 列标签\n",
    "display(df)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2b0e6096",
   "metadata": {},
   "source": [
    "## 返回属性n大或者n小的值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "id": "794ed576",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Pytorch</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>v</th>\n",
       "      <td>29</td>\n",
       "      <td>29</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>10</td>\n",
       "      <td>24</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>19</td>\n",
       "      <td>23</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>w</th>\n",
       "      <td>12</td>\n",
       "      <td>22</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>19</td>\n",
       "      <td>21</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>6</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>9</td>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>22</td>\n",
       "      <td>15</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>9</td>\n",
       "      <td>14</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Pytorch\n",
       "v      29     29       25\n",
       "f      10     24        6\n",
       "r      19     23        9\n",
       "h      28     23       11\n",
       "w      12     22       27\n",
       "a      19     21        2\n",
       "h       6     20       28\n",
       "i       9     17        1\n",
       "j      22     15        1\n",
       "e       9     14       29"
      ]
     },
     "execution_count": 188,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 返回属性n大或者n小的值\n",
    "df.nlargest(10, columns='Keras') # 根据属性Keras排序,返回最大10个数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 189,
   "id": "ea9ba2a9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Pytorch</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>0</td>\n",
       "      <td>13</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>y</th>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>6</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Pytorch\n",
       "f       0     13       21\n",
       "d       4      1       12\n",
       "r       4      1        9\n",
       "y       5      5        6\n",
       "h       6     20       28"
      ]
     },
     "execution_count": 189,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.nsmallest(5, columns='Python') # 根据属性Python排序，返回最小5个数据"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5f085ad0",
   "metadata": {},
   "source": [
    "## 索引列名排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 190,
   "id": "54de4bc0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Pytorch</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>y</th>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>w</th>\n",
       "      <td>12</td>\n",
       "      <td>22</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>v</th>\n",
       "      <td>29</td>\n",
       "      <td>29</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>u</th>\n",
       "      <td>29</td>\n",
       "      <td>5</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>t</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>s</th>\n",
       "      <td>13</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>19</td>\n",
       "      <td>23</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>q</th>\n",
       "      <td>18</td>\n",
       "      <td>1</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>o</th>\n",
       "      <td>28</td>\n",
       "      <td>8</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>n</th>\n",
       "      <td>29</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>26</td>\n",
       "      <td>12</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>22</td>\n",
       "      <td>15</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>19</td>\n",
       "      <td>3</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>9</td>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>6</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>22</td>\n",
       "      <td>14</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>10</td>\n",
       "      <td>24</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>20</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>0</td>\n",
       "      <td>13</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>9</td>\n",
       "      <td>14</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>11</td>\n",
       "      <td>13</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>21</td>\n",
       "      <td>6</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>6</td>\n",
       "      <td>13</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>28</td>\n",
       "      <td>4</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>19</td>\n",
       "      <td>21</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Pytorch\n",
       "y       5      5        6\n",
       "w      12     22       27\n",
       "v      29     29       25\n",
       "u      29      5       21\n",
       "t      12     13       10\n",
       "s      13      8        3\n",
       "r       4      1        9\n",
       "r      19     23        9\n",
       "q      18      1       16\n",
       "o      28      8       26\n",
       "n      29      6        3\n",
       "j      26     12       11\n",
       "j      22     15        1\n",
       "i      19      3       29\n",
       "i       9     17        1\n",
       "h       6     20       28\n",
       "h      28     23       11\n",
       "g      17      1       14\n",
       "g      22     14       11\n",
       "f      10     24        6\n",
       "f      20      9       10\n",
       "f       0     13       21\n",
       "e       7      9       10\n",
       "e       9     14       29\n",
       "d       4      1       12\n",
       "c      11     13        1\n",
       "c      21      6       22\n",
       "c       6     13        7\n",
       "b      28      4       16\n",
       "a      19     21        2"
      ]
     },
     "execution_count": 190,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 索引列名排序\n",
    "df.sort_index(axis = 0,ascending=False) # 按行索引排序，降序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 191,
   "id": "b0001b0e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Pytorch</th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>q</th>\n",
       "      <td>16</td>\n",
       "      <td>18</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>w</th>\n",
       "      <td>27</td>\n",
       "      <td>12</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>9</td>\n",
       "      <td>19</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>t</th>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>y</th>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>u</th>\n",
       "      <td>21</td>\n",
       "      <td>29</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>o</th>\n",
       "      <td>26</td>\n",
       "      <td>28</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>29</td>\n",
       "      <td>19</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>28</td>\n",
       "      <td>6</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>2</td>\n",
       "      <td>19</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>s</th>\n",
       "      <td>3</td>\n",
       "      <td>13</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>12</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>1</td>\n",
       "      <td>11</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>v</th>\n",
       "      <td>25</td>\n",
       "      <td>29</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>16</td>\n",
       "      <td>28</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>n</th>\n",
       "      <td>3</td>\n",
       "      <td>29</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>10</td>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>9</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>6</td>\n",
       "      <td>10</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>11</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>10</td>\n",
       "      <td>20</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Pytorch  Python  Keras\n",
       "q       16      18      1\n",
       "w       27      12     22\n",
       "e       29       9     14\n",
       "r        9      19     23\n",
       "t       10      12     13\n",
       "y        6       5      5\n",
       "u       21      29      5\n",
       "i        1       9     17\n",
       "o       26      28      8\n",
       "i       29      19      3\n",
       "j        1      22     15\n",
       "h       28       6     20\n",
       "g       14      17      1\n",
       "f       21       0     13\n",
       "c       22      21      6\n",
       "a        2      19     21\n",
       "s        3      13      8\n",
       "d       12       4      1\n",
       "c        1      11     13\n",
       "v       25      29     29\n",
       "b       16      28      4\n",
       "n        3      29      6\n",
       "e       10       7      9\n",
       "r        9       4      1\n",
       "f        6      10     24\n",
       "g       11      22     14\n",
       "h       11      28     23\n",
       "j       11      26     12\n",
       "c        7       6     13\n",
       "f       10      20      9"
      ]
     },
     "execution_count": 191,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_index(axis = 1,ascending=False) #按列名排序，升序"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e84c52d1",
   "metadata": {},
   "source": [
    "## 属性值排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 192,
   "id": "fc485b76",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Pytorch</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>0</td>\n",
       "      <td>13</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>y</th>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>6</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>6</td>\n",
       "      <td>13</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>9</td>\n",
       "      <td>14</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>9</td>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>10</td>\n",
       "      <td>24</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>11</td>\n",
       "      <td>13</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>w</th>\n",
       "      <td>12</td>\n",
       "      <td>22</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>t</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>s</th>\n",
       "      <td>13</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>q</th>\n",
       "      <td>18</td>\n",
       "      <td>1</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>19</td>\n",
       "      <td>23</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>19</td>\n",
       "      <td>21</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>19</td>\n",
       "      <td>3</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>20</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>21</td>\n",
       "      <td>6</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>22</td>\n",
       "      <td>15</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>22</td>\n",
       "      <td>14</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>26</td>\n",
       "      <td>12</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>28</td>\n",
       "      <td>4</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>o</th>\n",
       "      <td>28</td>\n",
       "      <td>8</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>n</th>\n",
       "      <td>29</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>u</th>\n",
       "      <td>29</td>\n",
       "      <td>5</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>v</th>\n",
       "      <td>29</td>\n",
       "      <td>29</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Pytorch\n",
       "f       0     13       21\n",
       "r       4      1        9\n",
       "d       4      1       12\n",
       "y       5      5        6\n",
       "h       6     20       28\n",
       "c       6     13        7\n",
       "e       7      9       10\n",
       "e       9     14       29\n",
       "i       9     17        1\n",
       "f      10     24        6\n",
       "c      11     13        1\n",
       "w      12     22       27\n",
       "t      12     13       10\n",
       "s      13      8        3\n",
       "g      17      1       14\n",
       "q      18      1       16\n",
       "r      19     23        9\n",
       "a      19     21        2\n",
       "i      19      3       29\n",
       "f      20      9       10\n",
       "c      21      6       22\n",
       "j      22     15        1\n",
       "g      22     14       11\n",
       "j      26     12       11\n",
       "b      28      4       16\n",
       "o      28      8       26\n",
       "h      28     23       11\n",
       "n      29      6        3\n",
       "u      29      5       21\n",
       "v      29     29       25"
      ]
     },
     "execution_count": 192,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 属性值排序\n",
    "df.sort_values(by = ['Python']) #按 Python属性值排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 193,
   "id": "8d26b6b4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Pytorch</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>0</td>\n",
       "      <td>13</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>y</th>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>6</td>\n",
       "      <td>13</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>6</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>9</td>\n",
       "      <td>14</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>9</td>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>10</td>\n",
       "      <td>24</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>11</td>\n",
       "      <td>13</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>t</th>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>w</th>\n",
       "      <td>12</td>\n",
       "      <td>22</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>s</th>\n",
       "      <td>13</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>q</th>\n",
       "      <td>18</td>\n",
       "      <td>1</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>19</td>\n",
       "      <td>3</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>19</td>\n",
       "      <td>21</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>r</th>\n",
       "      <td>19</td>\n",
       "      <td>23</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>20</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>21</td>\n",
       "      <td>6</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>22</td>\n",
       "      <td>14</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>22</td>\n",
       "      <td>15</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>26</td>\n",
       "      <td>12</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>28</td>\n",
       "      <td>4</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>o</th>\n",
       "      <td>28</td>\n",
       "      <td>8</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>u</th>\n",
       "      <td>29</td>\n",
       "      <td>5</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>n</th>\n",
       "      <td>29</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>v</th>\n",
       "      <td>29</td>\n",
       "      <td>29</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Python  Keras  Pytorch\n",
       "f       0     13       21\n",
       "d       4      1       12\n",
       "r       4      1        9\n",
       "y       5      5        6\n",
       "c       6     13        7\n",
       "h       6     20       28\n",
       "e       7      9       10\n",
       "e       9     14       29\n",
       "i       9     17        1\n",
       "f      10     24        6\n",
       "c      11     13        1\n",
       "t      12     13       10\n",
       "w      12     22       27\n",
       "s      13      8        3\n",
       "g      17      1       14\n",
       "q      18      1       16\n",
       "i      19      3       29\n",
       "a      19     21        2\n",
       "r      19     23        9\n",
       "f      20      9       10\n",
       "c      21      6       22\n",
       "g      22     14       11\n",
       "j      22     15        1\n",
       "j      26     12       11\n",
       "b      28      4       16\n",
       "o      28      8       26\n",
       "h      28     23       11\n",
       "u      29      5       21\n",
       "n      29      6        3\n",
       "v      29     29       25"
      ]
     },
     "execution_count": 193,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_values(by = ['Python','Keras'])#先按 Python，再按 Keras排序"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6dc4d8e",
   "metadata": {},
   "source": [
    "# 分箱操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 194,
   "id": "e2b5c3bc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>50</td>\n",
       "      <td>60</td>\n",
       "      <td>124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>117</td>\n",
       "      <td>111</td>\n",
       "      <td>54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>15</td>\n",
       "      <td>134</td>\n",
       "      <td>99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>96</td>\n",
       "      <td>128</td>\n",
       "      <td>143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>139</td>\n",
       "      <td>146</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>95</th>\n",
       "      <td>80</td>\n",
       "      <td>61</td>\n",
       "      <td>118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96</th>\n",
       "      <td>22</td>\n",
       "      <td>45</td>\n",
       "      <td>105</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>97</th>\n",
       "      <td>148</td>\n",
       "      <td>111</td>\n",
       "      <td>117</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98</th>\n",
       "      <td>128</td>\n",
       "      <td>131</td>\n",
       "      <td>124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>99</th>\n",
       "      <td>104</td>\n",
       "      <td>31</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>100 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    Python  Tensorflow  Keras\n",
       "0       50          60    124\n",
       "1      117         111     54\n",
       "2       15         134     99\n",
       "3       96         128    143\n",
       "4      139         146     19\n",
       "..     ...         ...    ...\n",
       "95      80          61    118\n",
       "96      22          45    105\n",
       "97     148         111    117\n",
       "98     128         131    124\n",
       "99     104          31     35\n",
       "\n",
       "[100 rows x 3 columns]"
      ]
     },
     "execution_count": 194,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(data = np.random.randint(0, 150, size = (100,3)),\n",
    "                  columns=['Python','Tensorflow','Keras'])\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "da7dd633",
   "metadata": {},
   "source": [
    "## 等频分箱"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 195,
   "id": "3bcc63cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     中\n",
       "1     优\n",
       "2     差\n",
       "3     良\n",
       "4     优\n",
       "     ..\n",
       "95    良\n",
       "96    差\n",
       "97    优\n",
       "98    优\n",
       "99    良\n",
       "Name: Python, Length: 100, dtype: category\n",
       "Categories (4, object): ['差' < '中' < '良' < '优']"
      ]
     },
     "execution_count": 195,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 等频分箱\n",
    "pd.qcut(df.Python, \n",
    "        q = 4, # 4等分\n",
    "        labels=['差','中','良','优']) # 分箱后的分类"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 199,
   "id": "700144f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "差    25\n",
       "中    25\n",
       "良    25\n",
       "优    25\n",
       "Name: Python, dtype: int64"
      ]
     },
     "execution_count": 199,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 等频分箱\n",
    "pd.qcut(df.Python,q = 4,# 4等分\n",
    "        labels=['差','中','良','优']).value_counts() # 分箱后分类"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "098dee71",
   "metadata": {},
   "source": [
    "## 等宽分箱"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "id": "c5ff272b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     (49.333, 98.667]\n",
       "1      (98.667, 148.0]\n",
       "2     (-0.148, 49.333]\n",
       "3     (49.333, 98.667]\n",
       "4      (98.667, 148.0]\n",
       "            ...       \n",
       "95    (49.333, 98.667]\n",
       "96    (-0.148, 49.333]\n",
       "97     (98.667, 148.0]\n",
       "98     (98.667, 148.0]\n",
       "99     (98.667, 148.0]\n",
       "Name: Python, Length: 100, dtype: category\n",
       "Categories (3, interval[float64, right]): [(-0.148, 49.333] < (49.333, 98.667] < (98.667, 148.0]]"
      ]
     },
     "execution_count": 196,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 等宽分箱\n",
    "pd.cut(df.Python, bins = 3) # 分成 3箱"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e9fe1d4",
   "metadata": {},
   "source": [
    "## 指定宽度分箱"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 197,
   "id": "e62e5a20",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      优秀\n",
       "1     不及格\n",
       "2      良好\n",
       "3      优秀\n",
       "4     不及格\n",
       "     ... \n",
       "95     良好\n",
       "96     良好\n",
       "97     良好\n",
       "98     优秀\n",
       "99    不及格\n",
       "Name: Keras, Length: 100, dtype: category\n",
       "Categories (4, object): ['不及格' < '中等' < '良好' < '优秀']"
      ]
     },
     "execution_count": 197,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 指定宽度分箱\n",
    "t = pd.cut(df.Keras,#分箱数据\n",
    "       bins = [0,60,90,120,150], # 分箱断点\n",
    "       right = False, # 左闭右开\n",
    "       labels=['不及格','中等','良好','优秀'])# 分箱后分类\n",
    "t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 201,
   "id": "a2b5a25a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      60\n",
       "1      54\n",
       "2      99\n",
       "3     143\n",
       "4      19\n",
       "     ... \n",
       "95    118\n",
       "96    105\n",
       "97    117\n",
       "98    124\n",
       "99     35\n",
       "Name: Keras, Length: 100, dtype: int64"
      ]
     },
     "execution_count": 201,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.Keras"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 200,
   "id": "22346b22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      中等\n",
       "1     不及格\n",
       "2      良好\n",
       "3      优秀\n",
       "4     不及格\n",
       "     ... \n",
       "95     良好\n",
       "96     良好\n",
       "97     良好\n",
       "98     优秀\n",
       "99    不及格\n",
       "Name: Keras, Length: 100, dtype: object"
      ]
     },
     "execution_count": 200,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def convert(x):\n",
    "    if x < 60:\n",
    "        return '不及格'\n",
    "    elif x < 90:\n",
    "        return '中等'\n",
    "    elif x < 120:\n",
    "        return '良好'\n",
    "    else:\n",
    "        return '优秀'\n",
    "df.Keras.map(convert)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "756c5655",
   "metadata": {},
   "source": [
    "# 分组聚合"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b59fe43",
   "metadata": {},
   "source": [
    "## 分组"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "15c24d18",
   "metadata": {},
   "source": [
    "\n",
    "![](2_Pandas数据分析库_images/4.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 202,
   "id": "4e0dc1a3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sex</th>\n",
       "      <th>class</th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Java</th>\n",
       "      <th>C++</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>女</td>\n",
       "      <td>4</td>\n",
       "      <td>87</td>\n",
       "      <td>117</td>\n",
       "      <td>11</td>\n",
       "      <td>99</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>男</td>\n",
       "      <td>2</td>\n",
       "      <td>103</td>\n",
       "      <td>54</td>\n",
       "      <td>21</td>\n",
       "      <td>132</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>女</td>\n",
       "      <td>6</td>\n",
       "      <td>53</td>\n",
       "      <td>45</td>\n",
       "      <td>49</td>\n",
       "      <td>116</td>\n",
       "      <td>57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>女</td>\n",
       "      <td>6</td>\n",
       "      <td>60</td>\n",
       "      <td>38</td>\n",
       "      <td>116</td>\n",
       "      <td>128</td>\n",
       "      <td>92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>女</td>\n",
       "      <td>1</td>\n",
       "      <td>8</td>\n",
       "      <td>24</td>\n",
       "      <td>4</td>\n",
       "      <td>107</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>295</th>\n",
       "      <td>女</td>\n",
       "      <td>3</td>\n",
       "      <td>55</td>\n",
       "      <td>56</td>\n",
       "      <td>62</td>\n",
       "      <td>142</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>296</th>\n",
       "      <td>男</td>\n",
       "      <td>6</td>\n",
       "      <td>146</td>\n",
       "      <td>150</td>\n",
       "      <td>121</td>\n",
       "      <td>52</td>\n",
       "      <td>105</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>297</th>\n",
       "      <td>男</td>\n",
       "      <td>8</td>\n",
       "      <td>134</td>\n",
       "      <td>92</td>\n",
       "      <td>78</td>\n",
       "      <td>125</td>\n",
       "      <td>112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>298</th>\n",
       "      <td>男</td>\n",
       "      <td>7</td>\n",
       "      <td>44</td>\n",
       "      <td>72</td>\n",
       "      <td>30</td>\n",
       "      <td>37</td>\n",
       "      <td>136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>299</th>\n",
       "      <td>男</td>\n",
       "      <td>4</td>\n",
       "      <td>21</td>\n",
       "      <td>122</td>\n",
       "      <td>26</td>\n",
       "      <td>30</td>\n",
       "      <td>107</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>300 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    sex  class  Python  Keras  Tensorflow  Java  C++\n",
       "0     女      4      87    117          11    99   48\n",
       "1     男      2     103     54          21   132   68\n",
       "2     女      6      53     45          49   116   57\n",
       "3     女      6      60     38         116   128   92\n",
       "4     女      1       8     24           4   107    9\n",
       "..   ..    ...     ...    ...         ...   ...  ...\n",
       "295   女      3      55     56          62   142   62\n",
       "296   男      6     146    150         121    52  105\n",
       "297   男      8     134     92          78   125  112\n",
       "298   男      7      44     72          30    37  136\n",
       "299   男      4      21    122          26    30  107\n",
       "\n",
       "[300 rows x 7 columns]"
      ]
     },
     "execution_count": 202,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "# 准备数据\n",
    "df = pd.DataFrame(data = {'sex':np.random.randint(0,2,size = 300), # 0男，1女\n",
    "                          'class':np.random.randint(1,9,size = 300), # 1 ~ 8八个班\n",
    "                          'Python':np.random.randint(0,151,size = 300), # Python成绩\n",
    "                          'Keras':np.random.randint(0,151,size =300), # Keras成绩\n",
    "                          'Tensorflow':np.random.randint(0,151,size=300),\n",
    "                          'Java':np.random.randint(0,151,size = 300),\n",
    "                          'C++':np.random.randint(0,151,size = 300)})\n",
    "df['sex'] = df['sex'].map({0:'男',1:'女'}) # 将0，1映射成男女\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 213,
   "id": "dd3b1c78",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "组名： 女\n",
      "数据：      Python  Java\n",
      "0        87    99\n",
      "2        53   116\n",
      "3        60   128\n",
      "4         8   107\n",
      "5       112   140\n",
      "..      ...   ...\n",
      "286      84    27\n",
      "292     133   130\n",
      "293     141    37\n",
      "294      21   126\n",
      "295      55   142\n",
      "\n",
      "[145 rows x 2 columns]\n",
      "组名： 男\n",
      "数据：      Python  Java\n",
      "1       103   132\n",
      "9        53    62\n",
      "11       53   146\n",
      "14       23    41\n",
      "15       59    15\n",
      "..      ...   ...\n",
      "291      93    83\n",
      "296     146    52\n",
      "297     134   125\n",
      "298      44    37\n",
      "299      21    30\n",
      "\n",
      "[155 rows x 2 columns]\n"
     ]
    }
   ],
   "source": [
    "# 1.1 先分组再获取数据 \n",
    "g = df.groupby(by = 'sex')[['Python','Java']] # 单分组 \n",
    "\n",
    "for name,data in g: \n",
    "    print('组名：',name) \n",
    "    print('数据：',data) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 214,
   "id": "f75f5bba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pandas.core.groupby.generic.DataFrameGroupBy object at 0x178241880>"
      ]
     },
     "execution_count": 214,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(by = ['class','sex'])[['Python']] # 多分组 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 215,
   "id": "c33a8083",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pandas.core.groupby.generic.SeriesGroupBy object at 0x17824f6a0>"
      ]
     },
     "execution_count": 215,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1.2 对一列值进行分组 \n",
    "df['Python'].groupby(df['class']) # 单分组 \n",
    "df['Keras'].groupby([df['class'],df['sex']]) # 多分组 \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 216,
   "id": "778a3650",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pandas.core.groupby.generic.DataFrameGroupBy object at 0x178261a30>"
      ]
     },
     "execution_count": 216,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1.3 按数据类型分组 \n",
    "df.groupby(df.dtypes, axis = 1) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 217,
   "id": "e0aafef3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "组名 IT\n",
      "数据      Python  Keras  Java  C++\n",
      "0        87    117    99   48\n",
      "1       103     54   132   68\n",
      "2        53     45   116   57\n",
      "3        60     38   128   92\n",
      "4         8     24   107    9\n",
      "..      ...    ...   ...  ...\n",
      "295      55     56   142   62\n",
      "296     146    150    52  105\n",
      "297     134     92   125  112\n",
      "298      44     72    37  136\n",
      "299      21    122    30  107\n",
      "\n",
      "[300 rows x 4 columns]\n",
      "组名 IT \n",
      "数据      Tensorflow\n",
      "0            11\n",
      "1            21\n",
      "2            49\n",
      "3           116\n",
      "4             4\n",
      "..          ...\n",
      "295          62\n",
      "296         121\n",
      "297          78\n",
      "298          30\n",
      "299          26\n",
      "\n",
      "[300 rows x 1 columns]\n",
      "组名 category\n",
      "数据     sex  class\n",
      "0     女      4\n",
      "1     男      2\n",
      "2     女      6\n",
      "3     女      6\n",
      "4     女      1\n",
      "..   ..    ...\n",
      "295   女      3\n",
      "296   男      6\n",
      "297   男      8\n",
      "298   男      7\n",
      "299   男      4\n",
      "\n",
      "[300 rows x 2 columns]\n"
     ]
    }
   ],
   "source": [
    "# 1.4 通过字典进行分组 \n",
    "m = {'sex':'category','class':'category','Python':'IT',\n",
    "     'Keras':'IT','Tensorflow':'IT ','Java':'IT','C++':'IT'} \n",
    "\n",
    "for name,data in df.groupby(m, axis = 1): \n",
    "    print('组名', name) \n",
    "    print('数据', data)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5dfb8f92",
   "metadata": {},
   "source": [
    "## 分组聚合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 218,
   "id": "df8558a0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>class</th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "      <th>Tensorflow</th>\n",
       "      <th>Java</th>\n",
       "      <th>C++</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sex</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>女</th>\n",
       "      <td>4.3</td>\n",
       "      <td>80.9</td>\n",
       "      <td>70.6</td>\n",
       "      <td>69.7</td>\n",
       "      <td>77.5</td>\n",
       "      <td>72.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>4.3</td>\n",
       "      <td>79.5</td>\n",
       "      <td>77.5</td>\n",
       "      <td>72.4</td>\n",
       "      <td>75.3</td>\n",
       "      <td>74.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     class  Python  Keras  Tensorflow  Java   C++\n",
       "sex                                              \n",
       "女      4.3    80.9   70.6        69.7  77.5  72.6\n",
       "男      4.3    79.5   77.5        72.4  75.3  74.2"
      ]
     },
     "execution_count": 218,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 分组直接调用函数进行聚合 \n",
    "# 按照性别分组，其他列均值聚合 \n",
    "df.groupby(by = 'sex').mean().round(1) # 保留1位小数 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 219,
   "id": "43e1f140",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>class</th>\n",
       "      <th>sex</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">1</th>\n",
       "      <th>女</th>\n",
       "      <td>121</td>\n",
       "      <td>136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>148</td>\n",
       "      <td>150</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">2</th>\n",
       "      <th>女</th>\n",
       "      <td>148</td>\n",
       "      <td>139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>132</td>\n",
       "      <td>137</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">3</th>\n",
       "      <th>女</th>\n",
       "      <td>149</td>\n",
       "      <td>143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>144</td>\n",
       "      <td>148</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">4</th>\n",
       "      <th>女</th>\n",
       "      <td>141</td>\n",
       "      <td>142</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>149</td>\n",
       "      <td>143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">5</th>\n",
       "      <th>女</th>\n",
       "      <td>147</td>\n",
       "      <td>143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>149</td>\n",
       "      <td>147</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">6</th>\n",
       "      <th>女</th>\n",
       "      <td>150</td>\n",
       "      <td>140</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>150</td>\n",
       "      <td>150</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">7</th>\n",
       "      <th>女</th>\n",
       "      <td>122</td>\n",
       "      <td>139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>147</td>\n",
       "      <td>141</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">8</th>\n",
       "      <th>女</th>\n",
       "      <td>142</td>\n",
       "      <td>137</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>150</td>\n",
       "      <td>138</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           Python  Keras\n",
       "class sex               \n",
       "1     女       121    136\n",
       "      男       148    150\n",
       "2     女       148    139\n",
       "      男       132    137\n",
       "3     女       149    143\n",
       "      男       144    148\n",
       "4     女       141    142\n",
       "      男       149    143\n",
       "5     女       147    143\n",
       "      男       149    147\n",
       "6     女       150    140\n",
       "      男       150    150\n",
       "7     女       122    139\n",
       "      男       147    141\n",
       "8     女       142    137\n",
       "      男       150    138"
      ]
     },
     "execution_count": 219,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 按照班级和性别进行分组，Python、Keras的最大值聚合 \n",
    "df.groupby(by = ['class','sex'])[['Python','Keras']].max() \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 220,
   "id": "c9b266c0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "class  sex\n",
       "1      女      23\n",
       "       男      24\n",
       "2      女      18\n",
       "       男      23\n",
       "3      女      18\n",
       "       男      18\n",
       "4      女      19\n",
       "       男      17\n",
       "5      女      18\n",
       "       男      17\n",
       "6      女      20\n",
       "       男      23\n",
       "7      女      14\n",
       "       男      17\n",
       "8      女      15\n",
       "       男      16\n",
       "dtype: int64"
      ]
     },
     "execution_count": 220,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 按照班级和性别进行分组，计数聚合。统计每个班，男女人数 \n",
    "df.groupby(by = ['class','sex']).size() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 221,
   "id": "caf4684b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th colspan=\"8\" halign=\"left\">Python</th>\n",
       "      <th colspan=\"2\" halign=\"left\">Keras</th>\n",
       "      <th>...</th>\n",
       "      <th colspan=\"2\" halign=\"left\">Java</th>\n",
       "      <th colspan=\"8\" halign=\"left\">C++</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>...</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>class</th>\n",
       "      <th>sex</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">1</th>\n",
       "      <th>女</th>\n",
       "      <td>23.0</td>\n",
       "      <td>66.000000</td>\n",
       "      <td>39.830322</td>\n",
       "      <td>0.0</td>\n",
       "      <td>36.50</td>\n",
       "      <td>67.0</td>\n",
       "      <td>101.00</td>\n",
       "      <td>121.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>61.608696</td>\n",
       "      <td>...</td>\n",
       "      <td>110.00</td>\n",
       "      <td>141.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>67.652174</td>\n",
       "      <td>47.680384</td>\n",
       "      <td>7.0</td>\n",
       "      <td>22.50</td>\n",
       "      <td>70.0</td>\n",
       "      <td>105.50</td>\n",
       "      <td>143.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>24.0</td>\n",
       "      <td>84.708333</td>\n",
       "      <td>41.414636</td>\n",
       "      <td>0.0</td>\n",
       "      <td>51.75</td>\n",
       "      <td>87.5</td>\n",
       "      <td>124.00</td>\n",
       "      <td>148.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>82.875000</td>\n",
       "      <td>...</td>\n",
       "      <td>90.25</td>\n",
       "      <td>148.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>71.333333</td>\n",
       "      <td>41.182169</td>\n",
       "      <td>1.0</td>\n",
       "      <td>43.75</td>\n",
       "      <td>72.0</td>\n",
       "      <td>100.25</td>\n",
       "      <td>142.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">2</th>\n",
       "      <th>女</th>\n",
       "      <td>18.0</td>\n",
       "      <td>83.944444</td>\n",
       "      <td>40.381231</td>\n",
       "      <td>2.0</td>\n",
       "      <td>53.00</td>\n",
       "      <td>85.0</td>\n",
       "      <td>114.00</td>\n",
       "      <td>148.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>77.277778</td>\n",
       "      <td>...</td>\n",
       "      <td>114.75</td>\n",
       "      <td>145.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>68.055556</td>\n",
       "      <td>47.402497</td>\n",
       "      <td>1.0</td>\n",
       "      <td>32.25</td>\n",
       "      <td>62.5</td>\n",
       "      <td>107.75</td>\n",
       "      <td>143.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>23.0</td>\n",
       "      <td>68.608696</td>\n",
       "      <td>36.251319</td>\n",
       "      <td>1.0</td>\n",
       "      <td>38.50</td>\n",
       "      <td>75.0</td>\n",
       "      <td>99.00</td>\n",
       "      <td>132.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>80.260870</td>\n",
       "      <td>...</td>\n",
       "      <td>117.50</td>\n",
       "      <td>132.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>65.173913</td>\n",
       "      <td>37.101399</td>\n",
       "      <td>4.0</td>\n",
       "      <td>29.50</td>\n",
       "      <td>68.0</td>\n",
       "      <td>91.00</td>\n",
       "      <td>134.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">3</th>\n",
       "      <th>女</th>\n",
       "      <td>18.0</td>\n",
       "      <td>83.166667</td>\n",
       "      <td>46.465990</td>\n",
       "      <td>6.0</td>\n",
       "      <td>56.75</td>\n",
       "      <td>78.5</td>\n",
       "      <td>131.25</td>\n",
       "      <td>149.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>66.888889</td>\n",
       "      <td>...</td>\n",
       "      <td>127.75</td>\n",
       "      <td>148.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>78.833333</td>\n",
       "      <td>45.412165</td>\n",
       "      <td>6.0</td>\n",
       "      <td>46.50</td>\n",
       "      <td>83.0</td>\n",
       "      <td>120.25</td>\n",
       "      <td>147.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>18.0</td>\n",
       "      <td>83.388889</td>\n",
       "      <td>41.973576</td>\n",
       "      <td>11.0</td>\n",
       "      <td>54.50</td>\n",
       "      <td>80.0</td>\n",
       "      <td>119.75</td>\n",
       "      <td>144.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>73.222222</td>\n",
       "      <td>...</td>\n",
       "      <td>121.50</td>\n",
       "      <td>147.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>79.611111</td>\n",
       "      <td>41.871145</td>\n",
       "      <td>9.0</td>\n",
       "      <td>46.50</td>\n",
       "      <td>85.5</td>\n",
       "      <td>100.25</td>\n",
       "      <td>149.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">4</th>\n",
       "      <th>女</th>\n",
       "      <td>19.0</td>\n",
       "      <td>73.000000</td>\n",
       "      <td>46.001208</td>\n",
       "      <td>3.0</td>\n",
       "      <td>27.00</td>\n",
       "      <td>76.0</td>\n",
       "      <td>112.00</td>\n",
       "      <td>141.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>72.473684</td>\n",
       "      <td>...</td>\n",
       "      <td>106.00</td>\n",
       "      <td>143.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>81.789474</td>\n",
       "      <td>48.646776</td>\n",
       "      <td>1.0</td>\n",
       "      <td>38.50</td>\n",
       "      <td>87.0</td>\n",
       "      <td>124.00</td>\n",
       "      <td>146.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>17.0</td>\n",
       "      <td>76.294118</td>\n",
       "      <td>52.924197</td>\n",
       "      <td>2.0</td>\n",
       "      <td>37.00</td>\n",
       "      <td>61.0</td>\n",
       "      <td>120.00</td>\n",
       "      <td>149.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>78.176471</td>\n",
       "      <td>...</td>\n",
       "      <td>120.00</td>\n",
       "      <td>148.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>57.705882</td>\n",
       "      <td>37.200075</td>\n",
       "      <td>0.0</td>\n",
       "      <td>36.00</td>\n",
       "      <td>50.0</td>\n",
       "      <td>84.00</td>\n",
       "      <td>115.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">5</th>\n",
       "      <th>女</th>\n",
       "      <td>18.0</td>\n",
       "      <td>97.722222</td>\n",
       "      <td>36.081290</td>\n",
       "      <td>22.0</td>\n",
       "      <td>78.00</td>\n",
       "      <td>107.5</td>\n",
       "      <td>122.75</td>\n",
       "      <td>147.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>79.944444</td>\n",
       "      <td>...</td>\n",
       "      <td>95.50</td>\n",
       "      <td>144.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>64.000000</td>\n",
       "      <td>44.809400</td>\n",
       "      <td>3.0</td>\n",
       "      <td>24.75</td>\n",
       "      <td>60.5</td>\n",
       "      <td>92.00</td>\n",
       "      <td>142.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>17.0</td>\n",
       "      <td>71.470588</td>\n",
       "      <td>42.283445</td>\n",
       "      <td>0.0</td>\n",
       "      <td>40.00</td>\n",
       "      <td>56.0</td>\n",
       "      <td>98.00</td>\n",
       "      <td>149.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>86.058824</td>\n",
       "      <td>...</td>\n",
       "      <td>123.00</td>\n",
       "      <td>146.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>94.764706</td>\n",
       "      <td>45.272135</td>\n",
       "      <td>5.0</td>\n",
       "      <td>81.00</td>\n",
       "      <td>114.0</td>\n",
       "      <td>126.00</td>\n",
       "      <td>148.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">6</th>\n",
       "      <th>女</th>\n",
       "      <td>20.0</td>\n",
       "      <td>90.050000</td>\n",
       "      <td>41.290339</td>\n",
       "      <td>12.0</td>\n",
       "      <td>59.25</td>\n",
       "      <td>91.5</td>\n",
       "      <td>127.50</td>\n",
       "      <td>150.0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>60.300000</td>\n",
       "      <td>...</td>\n",
       "      <td>126.50</td>\n",
       "      <td>142.0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>69.500000</td>\n",
       "      <td>36.360042</td>\n",
       "      <td>12.0</td>\n",
       "      <td>33.75</td>\n",
       "      <td>68.0</td>\n",
       "      <td>94.50</td>\n",
       "      <td>131.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>23.0</td>\n",
       "      <td>87.826087</td>\n",
       "      <td>47.217728</td>\n",
       "      <td>7.0</td>\n",
       "      <td>49.00</td>\n",
       "      <td>97.0</td>\n",
       "      <td>123.50</td>\n",
       "      <td>150.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>68.086957</td>\n",
       "      <td>...</td>\n",
       "      <td>102.50</td>\n",
       "      <td>147.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>62.086957</td>\n",
       "      <td>42.394160</td>\n",
       "      <td>1.0</td>\n",
       "      <td>31.00</td>\n",
       "      <td>50.0</td>\n",
       "      <td>99.00</td>\n",
       "      <td>128.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">7</th>\n",
       "      <th>女</th>\n",
       "      <td>14.0</td>\n",
       "      <td>81.571429</td>\n",
       "      <td>40.462165</td>\n",
       "      <td>2.0</td>\n",
       "      <td>49.25</td>\n",
       "      <td>103.5</td>\n",
       "      <td>115.25</td>\n",
       "      <td>122.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>74.785714</td>\n",
       "      <td>...</td>\n",
       "      <td>116.50</td>\n",
       "      <td>149.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>81.357143</td>\n",
       "      <td>43.632393</td>\n",
       "      <td>0.0</td>\n",
       "      <td>65.75</td>\n",
       "      <td>79.0</td>\n",
       "      <td>114.75</td>\n",
       "      <td>147.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>17.0</td>\n",
       "      <td>85.117647</td>\n",
       "      <td>43.086950</td>\n",
       "      <td>20.0</td>\n",
       "      <td>54.00</td>\n",
       "      <td>93.0</td>\n",
       "      <td>126.00</td>\n",
       "      <td>147.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>75.411765</td>\n",
       "      <td>...</td>\n",
       "      <td>82.00</td>\n",
       "      <td>147.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>88.941176</td>\n",
       "      <td>41.398174</td>\n",
       "      <td>27.0</td>\n",
       "      <td>52.00</td>\n",
       "      <td>99.0</td>\n",
       "      <td>129.00</td>\n",
       "      <td>142.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">8</th>\n",
       "      <th>女</th>\n",
       "      <td>15.0</td>\n",
       "      <td>74.600000</td>\n",
       "      <td>43.396511</td>\n",
       "      <td>14.0</td>\n",
       "      <td>35.00</td>\n",
       "      <td>75.0</td>\n",
       "      <td>106.50</td>\n",
       "      <td>142.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>77.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>110.00</td>\n",
       "      <td>135.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>72.533333</td>\n",
       "      <td>49.087192</td>\n",
       "      <td>9.0</td>\n",
       "      <td>28.00</td>\n",
       "      <td>86.0</td>\n",
       "      <td>106.00</td>\n",
       "      <td>149.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>16.0</td>\n",
       "      <td>77.187500</td>\n",
       "      <td>48.404158</td>\n",
       "      <td>6.0</td>\n",
       "      <td>30.00</td>\n",
       "      <td>72.0</td>\n",
       "      <td>120.00</td>\n",
       "      <td>150.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>76.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>119.00</td>\n",
       "      <td>146.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>82.875000</td>\n",
       "      <td>48.416079</td>\n",
       "      <td>1.0</td>\n",
       "      <td>48.00</td>\n",
       "      <td>86.0</td>\n",
       "      <td>118.25</td>\n",
       "      <td>150.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>16 rows × 40 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          Python                                                           \\\n",
       "           count       mean        std   min    25%    50%     75%    max   \n",
       "class sex                                                                   \n",
       "1     女     23.0  66.000000  39.830322   0.0  36.50   67.0  101.00  121.0   \n",
       "      男     24.0  84.708333  41.414636   0.0  51.75   87.5  124.00  148.0   \n",
       "2     女     18.0  83.944444  40.381231   2.0  53.00   85.0  114.00  148.0   \n",
       "      男     23.0  68.608696  36.251319   1.0  38.50   75.0   99.00  132.0   \n",
       "3     女     18.0  83.166667  46.465990   6.0  56.75   78.5  131.25  149.0   \n",
       "      男     18.0  83.388889  41.973576  11.0  54.50   80.0  119.75  144.0   \n",
       "4     女     19.0  73.000000  46.001208   3.0  27.00   76.0  112.00  141.0   \n",
       "      男     17.0  76.294118  52.924197   2.0  37.00   61.0  120.00  149.0   \n",
       "5     女     18.0  97.722222  36.081290  22.0  78.00  107.5  122.75  147.0   \n",
       "      男     17.0  71.470588  42.283445   0.0  40.00   56.0   98.00  149.0   \n",
       "6     女     20.0  90.050000  41.290339  12.0  59.25   91.5  127.50  150.0   \n",
       "      男     23.0  87.826087  47.217728   7.0  49.00   97.0  123.50  150.0   \n",
       "7     女     14.0  81.571429  40.462165   2.0  49.25  103.5  115.25  122.0   \n",
       "      男     17.0  85.117647  43.086950  20.0  54.00   93.0  126.00  147.0   \n",
       "8     女     15.0  74.600000  43.396511  14.0  35.00   75.0  106.50  142.0   \n",
       "      男     16.0  77.187500  48.404158   6.0  30.00   72.0  120.00  150.0   \n",
       "\n",
       "          Keras             ...    Java          C++                        \\\n",
       "          count       mean  ...     75%    max count       mean        std   \n",
       "class sex                   ...                                              \n",
       "1     女    23.0  61.608696  ...  110.00  141.0  23.0  67.652174  47.680384   \n",
       "      男    24.0  82.875000  ...   90.25  148.0  24.0  71.333333  41.182169   \n",
       "2     女    18.0  77.277778  ...  114.75  145.0  18.0  68.055556  47.402497   \n",
       "      男    23.0  80.260870  ...  117.50  132.0  23.0  65.173913  37.101399   \n",
       "3     女    18.0  66.888889  ...  127.75  148.0  18.0  78.833333  45.412165   \n",
       "      男    18.0  73.222222  ...  121.50  147.0  18.0  79.611111  41.871145   \n",
       "4     女    19.0  72.473684  ...  106.00  143.0  19.0  81.789474  48.646776   \n",
       "      男    17.0  78.176471  ...  120.00  148.0  17.0  57.705882  37.200075   \n",
       "5     女    18.0  79.944444  ...   95.50  144.0  18.0  64.000000  44.809400   \n",
       "      男    17.0  86.058824  ...  123.00  146.0  17.0  94.764706  45.272135   \n",
       "6     女    20.0  60.300000  ...  126.50  142.0  20.0  69.500000  36.360042   \n",
       "      男    23.0  68.086957  ...  102.50  147.0  23.0  62.086957  42.394160   \n",
       "7     女    14.0  74.785714  ...  116.50  149.0  14.0  81.357143  43.632393   \n",
       "      男    17.0  75.411765  ...   82.00  147.0  17.0  88.941176  41.398174   \n",
       "8     女    15.0  77.000000  ...  110.00  135.0  15.0  72.533333  49.087192   \n",
       "      男    16.0  76.000000  ...  119.00  146.0  16.0  82.875000  48.416079   \n",
       "\n",
       "                                              \n",
       "            min    25%    50%     75%    max  \n",
       "class sex                                     \n",
       "1     女     7.0  22.50   70.0  105.50  143.0  \n",
       "      男     1.0  43.75   72.0  100.25  142.0  \n",
       "2     女     1.0  32.25   62.5  107.75  143.0  \n",
       "      男     4.0  29.50   68.0   91.00  134.0  \n",
       "3     女     6.0  46.50   83.0  120.25  147.0  \n",
       "      男     9.0  46.50   85.5  100.25  149.0  \n",
       "4     女     1.0  38.50   87.0  124.00  146.0  \n",
       "      男     0.0  36.00   50.0   84.00  115.0  \n",
       "5     女     3.0  24.75   60.5   92.00  142.0  \n",
       "      男     5.0  81.00  114.0  126.00  148.0  \n",
       "6     女    12.0  33.75   68.0   94.50  131.0  \n",
       "      男     1.0  31.00   50.0   99.00  128.0  \n",
       "7     女     0.0  65.75   79.0  114.75  147.0  \n",
       "      男    27.0  52.00   99.0  129.00  142.0  \n",
       "8     女     9.0  28.00   86.0  106.00  149.0  \n",
       "      男     1.0  48.00   86.0  118.25  150.0  \n",
       "\n",
       "[16 rows x 40 columns]"
      ]
     },
     "execution_count": 221,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 基本描述性统计聚合 \n",
    "df.groupby(by = ['class','sex']).describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "efed5267",
   "metadata": {},
   "source": [
    "## 分组聚合apply、transform"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d3bb544",
   "metadata": {},
   "source": [
    "\n",
    "![](2_Pandas数据分析库_images/5.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6ec5a7c4",
   "metadata": {},
   "source": [
    "\n",
    "![](2_Pandas数据分析库_images/6.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 222,
   "id": "43373bb3",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/macbook/opt/anaconda3/lib/python3.9/site-packages/numpy/core/fromnumeric.py:3462: FutureWarning: In a future version, DataFrame.mean(axis=None) will return a scalar mean over the entire DataFrame. To retain the old behavior, use 'frame.mean(axis=0)' or just 'frame.mean()'\n",
      "  return mean(axis=axis, dtype=dtype, out=out, **kwargs)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Keras</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>class</th>\n",
       "      <th>sex</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">1</th>\n",
       "      <th>女</th>\n",
       "      <td>66.0</td>\n",
       "      <td>61.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>84.7</td>\n",
       "      <td>82.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">2</th>\n",
       "      <th>女</th>\n",
       "      <td>83.9</td>\n",
       "      <td>77.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>68.6</td>\n",
       "      <td>80.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">3</th>\n",
       "      <th>女</th>\n",
       "      <td>83.2</td>\n",
       "      <td>66.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>83.4</td>\n",
       "      <td>73.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">4</th>\n",
       "      <th>女</th>\n",
       "      <td>73.0</td>\n",
       "      <td>72.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>76.3</td>\n",
       "      <td>78.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">5</th>\n",
       "      <th>女</th>\n",
       "      <td>97.7</td>\n",
       "      <td>79.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>71.5</td>\n",
       "      <td>86.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">6</th>\n",
       "      <th>女</th>\n",
       "      <td>90.0</td>\n",
       "      <td>60.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>87.8</td>\n",
       "      <td>68.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">7</th>\n",
       "      <th>女</th>\n",
       "      <td>81.6</td>\n",
       "      <td>74.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>85.1</td>\n",
       "      <td>75.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">8</th>\n",
       "      <th>女</th>\n",
       "      <td>74.6</td>\n",
       "      <td>77.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>77.2</td>\n",
       "      <td>76.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           Python  Keras\n",
       "class sex               \n",
       "1     女      66.0   61.6\n",
       "      男      84.7   82.9\n",
       "2     女      83.9   77.3\n",
       "      男      68.6   80.3\n",
       "3     女      83.2   66.9\n",
       "      男      83.4   73.2\n",
       "4     女      73.0   72.5\n",
       "      男      76.3   78.2\n",
       "5     女      97.7   79.9\n",
       "      男      71.5   86.1\n",
       "6     女      90.0   60.3\n",
       "      男      87.8   68.1\n",
       "7     女      81.6   74.8\n",
       "      男      85.1   75.4\n",
       "8     女      74.6   77.0\n",
       "      男      77.2   76.0"
      ]
     },
     "execution_count": 222,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 分组后调用apply，transform封装单一函数计算 \n",
    "# 返回分组结果 \n",
    "df.groupby(by = ['class','sex'])[['Python','Keras']].apply(np.mean).round(1) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 225,
   "id": "df28f530",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Python</th>\n",
       "      <th>Tensorflow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.609</td>\n",
       "      <td>0.021</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.779</td>\n",
       "      <td>0.106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.297</td>\n",
       "      <td>0.289</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.348</td>\n",
       "      <td>0.761</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.066</td>\n",
       "      <td>0.000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>295</th>\n",
       "      <td>0.343</td>\n",
       "      <td>0.403</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>296</th>\n",
       "      <td>0.972</td>\n",
       "      <td>0.829</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>297</th>\n",
       "      <td>0.889</td>\n",
       "      <td>0.524</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>298</th>\n",
       "      <td>0.189</td>\n",
       "      <td>0.200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>299</th>\n",
       "      <td>0.129</td>\n",
       "      <td>0.148</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>300 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Python  Tensorflow\n",
       "0     0.609       0.021\n",
       "1     0.779       0.106\n",
       "2     0.297       0.289\n",
       "3     0.348       0.761\n",
       "4     0.066       0.000\n",
       "..      ...         ...\n",
       "295   0.343       0.403\n",
       "296   0.972       0.829\n",
       "297   0.889       0.524\n",
       "298   0.189       0.200\n",
       "299   0.129       0.148\n",
       "\n",
       "[300 rows x 2 columns]"
      ]
     },
     "execution_count": 225,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def normalization(x): \n",
    "    return (x - x.min())/(x.max() - x.min()) # 最大值最小值归一化 \n",
    "\n",
    "# 返回全数据，返回DataFrame.shape和原DataFrame.shape一样。 \n",
    "df.groupby(by = ['class','sex']) [['Python','Tensorflow']].transform(normalization).round(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "13804eab",
   "metadata": {},
   "source": [
    "## 分组聚合agg"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "09464459",
   "metadata": {},
   "source": [
    "\n",
    "![](2_Pandas数据分析库_images/7.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 227,
   "id": "7ea69928",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th colspan=\"3\" halign=\"left\">Tensorflow</th>\n",
       "      <th colspan=\"3\" halign=\"left\">Keras</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>amax</th>\n",
       "      <th>amin</th>\n",
       "      <th>count</th>\n",
       "      <th>amax</th>\n",
       "      <th>amin</th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>class</th>\n",
       "      <th>sex</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">1</th>\n",
       "      <th>女</th>\n",
       "      <td>147</td>\n",
       "      <td>4</td>\n",
       "      <td>23</td>\n",
       "      <td>136</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>144</td>\n",
       "      <td>15</td>\n",
       "      <td>24</td>\n",
       "      <td>150</td>\n",
       "      <td>2</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">2</th>\n",
       "      <th>女</th>\n",
       "      <td>146</td>\n",
       "      <td>0</td>\n",
       "      <td>18</td>\n",
       "      <td>139</td>\n",
       "      <td>5</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>147</td>\n",
       "      <td>6</td>\n",
       "      <td>23</td>\n",
       "      <td>137</td>\n",
       "      <td>1</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">3</th>\n",
       "      <th>女</th>\n",
       "      <td>145</td>\n",
       "      <td>6</td>\n",
       "      <td>18</td>\n",
       "      <td>143</td>\n",
       "      <td>2</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>145</td>\n",
       "      <td>1</td>\n",
       "      <td>18</td>\n",
       "      <td>148</td>\n",
       "      <td>8</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">4</th>\n",
       "      <th>女</th>\n",
       "      <td>149</td>\n",
       "      <td>8</td>\n",
       "      <td>19</td>\n",
       "      <td>142</td>\n",
       "      <td>2</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>141</td>\n",
       "      <td>6</td>\n",
       "      <td>17</td>\n",
       "      <td>143</td>\n",
       "      <td>9</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">5</th>\n",
       "      <th>女</th>\n",
       "      <td>122</td>\n",
       "      <td>1</td>\n",
       "      <td>18</td>\n",
       "      <td>143</td>\n",
       "      <td>1</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>147</td>\n",
       "      <td>6</td>\n",
       "      <td>17</td>\n",
       "      <td>147</td>\n",
       "      <td>32</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">6</th>\n",
       "      <th>女</th>\n",
       "      <td>150</td>\n",
       "      <td>8</td>\n",
       "      <td>20</td>\n",
       "      <td>140</td>\n",
       "      <td>1</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>146</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "      <td>150</td>\n",
       "      <td>2</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">7</th>\n",
       "      <th>女</th>\n",
       "      <td>140</td>\n",
       "      <td>2</td>\n",
       "      <td>14</td>\n",
       "      <td>139</td>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>138</td>\n",
       "      <td>3</td>\n",
       "      <td>17</td>\n",
       "      <td>141</td>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">8</th>\n",
       "      <th>女</th>\n",
       "      <td>135</td>\n",
       "      <td>1</td>\n",
       "      <td>15</td>\n",
       "      <td>137</td>\n",
       "      <td>6</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>146</td>\n",
       "      <td>3</td>\n",
       "      <td>16</td>\n",
       "      <td>138</td>\n",
       "      <td>19</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Tensorflow            Keras           \n",
       "                amax amin count  amax amin count\n",
       "class sex                                       \n",
       "1     女          147    4    23   136    0    23\n",
       "      男          144   15    24   150    2    24\n",
       "2     女          146    0    18   139    5    18\n",
       "      男          147    6    23   137    1    23\n",
       "3     女          145    6    18   143    2    18\n",
       "      男          145    1    18   148    8    18\n",
       "4     女          149    8    19   142    2    19\n",
       "      男          141    6    17   143    9    17\n",
       "5     女          122    1    18   143    1    18\n",
       "      男          147    6    17   147   32    17\n",
       "6     女          150    8    20   140    1    20\n",
       "      男          146    0    23   150    2    23\n",
       "7     女          140    2    14   139   13    14\n",
       "      男          138    3    17   141    0    17\n",
       "8     女          135    1    15   137    6    15\n",
       "      男          146    3    16   138   19    16"
      ]
     },
     "execution_count": 227,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# agg 多中统计汇总操作\n",
    "# 分组后调用 agg应用多种统计汇总\n",
    "df.groupby(by = ['class','sex'])[['Tensorflow','Keras']].agg([np.max, np.min, pd.Series.count])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 228,
   "id": "ff814c5f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th colspan=\"2\" halign=\"left\">Python</th>\n",
       "      <th colspan=\"2\" halign=\"left\">Keras</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>最大值</th>\n",
       "      <th>最小值</th>\n",
       "      <th>计数</th>\n",
       "      <th>中位数</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>class</th>\n",
       "      <th>sex</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">1</th>\n",
       "      <th>女</th>\n",
       "      <td>121</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "      <td>72.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>148</td>\n",
       "      <td>0</td>\n",
       "      <td>24</td>\n",
       "      <td>82.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">2</th>\n",
       "      <th>女</th>\n",
       "      <td>148</td>\n",
       "      <td>2</td>\n",
       "      <td>18</td>\n",
       "      <td>88.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>132</td>\n",
       "      <td>1</td>\n",
       "      <td>23</td>\n",
       "      <td>86.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">3</th>\n",
       "      <th>女</th>\n",
       "      <td>149</td>\n",
       "      <td>6</td>\n",
       "      <td>18</td>\n",
       "      <td>76.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>144</td>\n",
       "      <td>11</td>\n",
       "      <td>18</td>\n",
       "      <td>82.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">4</th>\n",
       "      <th>女</th>\n",
       "      <td>141</td>\n",
       "      <td>3</td>\n",
       "      <td>19</td>\n",
       "      <td>55.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>149</td>\n",
       "      <td>2</td>\n",
       "      <td>17</td>\n",
       "      <td>78.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">5</th>\n",
       "      <th>女</th>\n",
       "      <td>147</td>\n",
       "      <td>22</td>\n",
       "      <td>18</td>\n",
       "      <td>88.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>149</td>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "      <td>90.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">6</th>\n",
       "      <th>女</th>\n",
       "      <td>150</td>\n",
       "      <td>12</td>\n",
       "      <td>20</td>\n",
       "      <td>52.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>150</td>\n",
       "      <td>7</td>\n",
       "      <td>23</td>\n",
       "      <td>69.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">7</th>\n",
       "      <th>女</th>\n",
       "      <td>122</td>\n",
       "      <td>2</td>\n",
       "      <td>14</td>\n",
       "      <td>78.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>147</td>\n",
       "      <td>20</td>\n",
       "      <td>17</td>\n",
       "      <td>72.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">8</th>\n",
       "      <th>女</th>\n",
       "      <td>142</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "      <td>96.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>150</td>\n",
       "      <td>6</td>\n",
       "      <td>16</td>\n",
       "      <td>73.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Python     Keras      \n",
       "             最大值 最小值    计数   中位数\n",
       "class sex                       \n",
       "1     女      121   0    23  72.0\n",
       "      男      148   0    24  82.0\n",
       "2     女      148   2    18  88.0\n",
       "      男      132   1    23  86.0\n",
       "3     女      149   6    18  76.0\n",
       "      男      144  11    18  82.0\n",
       "4     女      141   3    19  55.0\n",
       "      男      149   2    17  78.0\n",
       "5     女      147  22    18  88.0\n",
       "      男      149   0    17  90.0\n",
       "6     女      150  12    20  52.5\n",
       "      男      150   7    23  69.0\n",
       "7     女      122   2    14  78.5\n",
       "      男      147  20    17  72.0\n",
       "8     女      142  14    15  96.0\n",
       "      男      150   6    16  73.5"
      ]
     },
     "execution_count": 228,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 分组后不同属性应用多种不同统计汇总\n",
    "df.groupby(by = ['class','sex'])[['Python','Keras']].agg({'Python':[('最大值',np.max),('最小值',np.min)],\n",
    "                                                          'Keras':[('计数',pd.Series.count),('中位数',np.median)]})"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "29f5922e",
   "metadata": {},
   "source": [
    "## 透视表\n",
    "透视表就是分组聚合pivot_table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 229,
   "id": "8167182a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th colspan=\"2\" halign=\"left\">Keras</th>\n",
       "      <th>Python</th>\n",
       "      <th colspan=\"3\" halign=\"left\">Tensorflow</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>中位数</th>\n",
       "      <th>最小值</th>\n",
       "      <th>最大值</th>\n",
       "      <th>平均值</th>\n",
       "      <th>最小值</th>\n",
       "      <th>计数</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>class</th>\n",
       "      <th>sex</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">1</th>\n",
       "      <th>女</th>\n",
       "      <td>72.0</td>\n",
       "      <td>0</td>\n",
       "      <td>121</td>\n",
       "      <td>80.000000</td>\n",
       "      <td>4</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>82.0</td>\n",
       "      <td>2</td>\n",
       "      <td>148</td>\n",
       "      <td>67.625000</td>\n",
       "      <td>15</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">2</th>\n",
       "      <th>女</th>\n",
       "      <td>88.0</td>\n",
       "      <td>5</td>\n",
       "      <td>148</td>\n",
       "      <td>84.166667</td>\n",
       "      <td>0</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>86.0</td>\n",
       "      <td>1</td>\n",
       "      <td>132</td>\n",
       "      <td>71.913043</td>\n",
       "      <td>6</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">3</th>\n",
       "      <th>女</th>\n",
       "      <td>76.0</td>\n",
       "      <td>2</td>\n",
       "      <td>149</td>\n",
       "      <td>71.444444</td>\n",
       "      <td>6</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>82.0</td>\n",
       "      <td>8</td>\n",
       "      <td>144</td>\n",
       "      <td>67.611111</td>\n",
       "      <td>1</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">4</th>\n",
       "      <th>女</th>\n",
       "      <td>55.0</td>\n",
       "      <td>2</td>\n",
       "      <td>141</td>\n",
       "      <td>60.684211</td>\n",
       "      <td>8</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>78.0</td>\n",
       "      <td>9</td>\n",
       "      <td>149</td>\n",
       "      <td>77.000000</td>\n",
       "      <td>6</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">5</th>\n",
       "      <th>女</th>\n",
       "      <td>88.0</td>\n",
       "      <td>1</td>\n",
       "      <td>147</td>\n",
       "      <td>57.666667</td>\n",
       "      <td>1</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>90.0</td>\n",
       "      <td>32</td>\n",
       "      <td>149</td>\n",
       "      <td>68.529412</td>\n",
       "      <td>6</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">6</th>\n",
       "      <th>女</th>\n",
       "      <td>52.5</td>\n",
       "      <td>1</td>\n",
       "      <td>150</td>\n",
       "      <td>79.950000</td>\n",
       "      <td>8</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>69.0</td>\n",
       "      <td>2</td>\n",
       "      <td>150</td>\n",
       "      <td>72.217391</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">7</th>\n",
       "      <th>女</th>\n",
       "      <td>78.5</td>\n",
       "      <td>13</td>\n",
       "      <td>122</td>\n",
       "      <td>54.571429</td>\n",
       "      <td>2</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>72.0</td>\n",
       "      <td>0</td>\n",
       "      <td>147</td>\n",
       "      <td>78.647059</td>\n",
       "      <td>3</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">8</th>\n",
       "      <th>女</th>\n",
       "      <td>96.0</td>\n",
       "      <td>6</td>\n",
       "      <td>142</td>\n",
       "      <td>60.800000</td>\n",
       "      <td>1</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男</th>\n",
       "      <td>73.5</td>\n",
       "      <td>19</td>\n",
       "      <td>150</td>\n",
       "      <td>78.437500</td>\n",
       "      <td>3</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Keras     Python Tensorflow        \n",
       "            中位数 最小值    最大值        平均值 最小值  计数\n",
       "class sex                                    \n",
       "1     女    72.0   0    121  80.000000   4  23\n",
       "      男    82.0   2    148  67.625000  15  24\n",
       "2     女    88.0   5    148  84.166667   0  18\n",
       "      男    86.0   1    132  71.913043   6  23\n",
       "3     女    76.0   2    149  71.444444   6  18\n",
       "      男    82.0   8    144  67.611111   1  18\n",
       "4     女    55.0   2    141  60.684211   8  19\n",
       "      男    78.0   9    149  77.000000   6  17\n",
       "5     女    88.0   1    147  57.666667   1  18\n",
       "      男    90.0  32    149  68.529412   6  17\n",
       "6     女    52.5   1    150  79.950000   8  20\n",
       "      男    69.0   2    150  72.217391   0  23\n",
       "7     女    78.5  13    122  54.571429   2  14\n",
       "      男    72.0   0    147  78.647059   3  17\n",
       "8     女    96.0   6    142  60.800000   1  15\n",
       "      男    73.5  19    150  78.437500   3  16"
      ]
     },
     "execution_count": 229,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 透视表\n",
    "# 透视表也是一种分组聚合运算\n",
    "def count(x):\n",
    "    return len(x)\n",
    "\n",
    "df.pivot_table(values=['Python','Keras','Tensorflow'], # 要透视分组的值\n",
    "               index=['class','sex'], # 分组透视指标,by = ['class','sex']\n",
    "               aggfunc={'Python':[('最大值',np.max)], # 聚合运算\n",
    "                        'Keras':[('最小值',np.min),('中位数',np.median)],\n",
    "                        'Tensorflow':[('最小值',np.min),('平均值',np.mean),('计数',count)]})"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "50098535",
   "metadata": {},
   "source": [
    "# 时间序列"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "613be4cc",
   "metadata": {},
   "source": [
    "## 时间戳操作"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7688b1a2",
   "metadata": {},
   "source": [
    "### 创建方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 230,
   "id": "4d18d03e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2020-08-24 12:00:00')"
      ]
     },
     "execution_count": 230,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Timestamp('2020-8-24 12') # 时刻数据 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 231,
   "id": "eb25d0be",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Period('2020-08', 'M')"
      ]
     },
     "execution_count": 231,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Period('2020-8-24',freq = 'M') # 时期数据 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 233,
   "id": "ee1669a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2020-08-31    3\n",
       "2020-09-30    0\n",
       "2020-10-31    6\n",
       "2020-11-30    2\n",
       "2020-12-31    1\n",
       "Freq: M, dtype: int64"
      ]
     },
     "execution_count": 233,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index = pd.date_range('2020.08.24',periods=5,freq = 'M') # 批量时刻数据 \n",
    "pd.period_range('2020.08.24',periods=5,freq='M') # 批量时期数据 \n",
    "\n",
    "ts = pd.Series(np.random.randint(0,10,size = 5),index = index) # 时间戳索引Series \n",
    "ts"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2f9cc6ac",
   "metadata": {},
   "source": [
    "### 转换方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 234,
   "id": "def3a874",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/0q/2y7xgmvn00b1090yx3d_n1140000gn/T/ipykernel_58118/444244512.py:2: UserWarning: Parsing '24/08/2020' in DD/MM/YYYY format. Provide format or specify infer_datetime_format=True for consistent parsing.\n",
      "  pd.to_datetime(['2020.08.24','2020-08-24','24/08/2020','2020/8/24'])\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2020-08-24', '2020-08-24', '2020-08-24', '2020-08-24'], dtype='datetime64[ns]', freq=None)"
      ]
     },
     "execution_count": 234,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 2、转换方法 \n",
    "pd.to_datetime(['2020.08.24','2020-08-24','24/08/2020','2020/8/24']) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 235,
   "id": "0e7441ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2020-08-28 02:37:12'], dtype='datetime64[ns]', freq=None)"
      ]
     },
     "execution_count": 235,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.to_datetime([1598582232],unit='s') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 237,
   "id": "2cbebb39",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2020-08-28 02:40:20.401000'], dtype='datetime64[ns]', freq=None)"
      ]
     },
     "execution_count": 237,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt = pd.to_datetime([1598582420401],unit = 'ms') # 世界标准时间 \n",
    "dt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 238,
   "id": "55172c9f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2020-08-28 10:40:20.401000'], dtype='datetime64[ns]', freq=None)"
      ]
     },
     "execution_count": 238,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt + pd.DateOffset(hours = 8) # 东八区时间 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 239,
   "id": "adc6e601",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2020-12-06 02:40:20.401000'], dtype='datetime64[ns]', freq=None)"
      ]
     },
     "execution_count": 239,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt + pd.DateOffset(days = 100) # 100天后日期"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "24b25b00",
   "metadata": {},
   "source": [
    "## 时间戳索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 241,
   "id": "715f67bf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2020-08-24      0\n",
       "2020-08-25      1\n",
       "2020-08-26      2\n",
       "2020-08-27      3\n",
       "2020-08-28      4\n",
       "             ... \n",
       "2021-03-07    195\n",
       "2021-03-08    196\n",
       "2021-03-09    197\n",
       "2021-03-10    198\n",
       "2021-03-11    199\n",
       "Freq: D, Length: 200, dtype: int64"
      ]
     },
     "execution_count": 241,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index = pd.date_range(\"2020-8-24\", periods=200, freq=\"D\") \n",
    "ts = pd.Series(range(len(index)), index=index) \n",
    "ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 242,
   "id": "9343fd4a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2020-08-24      0\n",
       "2020-08-25      1\n",
       "2020-08-26      2\n",
       "2020-08-27      3\n",
       "2020-08-28      4\n",
       "             ... \n",
       "2020-12-27    125\n",
       "2020-12-28    126\n",
       "2020-12-29    127\n",
       "2020-12-30    128\n",
       "2020-12-31    129\n",
       "Freq: D, Length: 130, dtype: int64"
      ]
     },
     "execution_count": 242,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# str类型索引 \n",
    "ts['2020-08-30'] # 日期访问数据 \n",
    "ts['2020-08-24':'2020-09-3'] # 日期切片 \n",
    "ts['2020-08'] # 传入年月 \n",
    "ts['2020'] # 传入年 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 243,
   "id": "875f08e4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2020-08-24    0\n",
       "2020-08-25    1\n",
       "2020-08-26    2\n",
       "2020-08-27    3\n",
       "2020-08-28    4\n",
       "2020-08-29    5\n",
       "2020-08-30    6\n",
       "2020-08-31    7\n",
       "2020-09-01    8\n",
       "2020-09-02    9\n",
       "Freq: D, dtype: int64"
      ]
     },
     "execution_count": 243,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 时间戳索引 \n",
    "ts[pd.Timestamp('2020-08-30')] \n",
    "ts[pd.Timestamp('2020-08-24'):pd.Timestamp('2020-08-30')] # 切片 \n",
    "\n",
    "ts[pd.date_range('2020-08-24',periods=10,freq='D')] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 244,
   "id": "a0102807",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/0q/2y7xgmvn00b1090yx3d_n1140000gn/T/ipykernel_58118/2513381943.py:4: FutureWarning: weekofyear and week have been deprecated, please use DatetimeIndex.isocalendar().week instead, which returns a Series. To exactly reproduce the behavior of week and weekofyear and return an Index, you may call pd.Int64Index(idx.isocalendar().week)\n",
      "  ts.index.weekofyear # 一年中第几个星期几\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Int64Index([35, 35, 35, 35, 35, 35, 35, 36, 36, 36,\n",
       "            ...\n",
       "             9,  9,  9,  9,  9,  9, 10, 10, 10, 10],\n",
       "           dtype='int64', length=200)"
      ]
     },
     "execution_count": 244,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 时间戳索引属性 \n",
    "ts.index.year # 获取年 \n",
    "ts.index.dayofweek # 获取星期几 \n",
    "ts.index.weekofyear # 一年中第几个星期"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dfbac7ce",
   "metadata": {},
   "source": [
    "## 时间序列常用方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 246,
   "id": "f357fdb9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2020-08-01 00:00:00     43\n",
       "2020-08-01 01:00:00      0\n",
       "2020-08-01 02:00:00      0\n",
       "2020-08-01 03:00:00      0\n",
       "2020-08-01 04:00:00      0\n",
       "                      ... \n",
       "2021-07-30 20:00:00      0\n",
       "2021-07-30 21:00:00      0\n",
       "2021-07-30 22:00:00      0\n",
       "2021-07-30 23:00:00      0\n",
       "2021-07-31 00:00:00    278\n",
       "Freq: H, Length: 8737, dtype: int64"
      ]
     },
     "execution_count": 246,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index = pd.date_range('8/1/2020', periods=365, freq='D') \n",
    "ts = pd.Series(np.random.randint(0, 500, len(index)), index=index) \n",
    "\n",
    "# 1、移动 \n",
    "ts.shift(periods = 2) # 数据后移 \n",
    "ts.shift(periods = -2) # 数据前移 \n",
    "\n",
    "# 日期移动 \n",
    "ts.shift(periods = 2,freq = pd.tseries.offsets.Day()) # 天移动 \n",
    "# ts.tshift(periods = 1,freq = pd.tseries.offsets.MonthOffset()) #月移动 \n",
    "\n",
    "# 2、频率转换 \n",
    "ts.asfreq(pd.tseries.offsets.Week()) # 天变周 \n",
    "ts.asfreq(pd.tseries.offsets.MonthEnd()) # 天变月 \n",
    "ts.asfreq(pd.tseries.offsets.Hour(),fill_value = 0) #天变小时，又少变多，fill_value 为填充值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 247,
   "id": "8e88c24d",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/macbook/opt/anaconda3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3397: UserWarning: Parsing '24/08/2020' in DD/MM/YYYY format. Provide format or specify infer_datetime_format=True for consistent parsing.\n",
      "  exec(code_obj, self.user_global_ns, self.user_ns)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>price</th>\n",
       "      <th>volume</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-01-08</th>\n",
       "      <td>21</td>\n",
       "      <td>110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-09</th>\n",
       "      <td>22</td>\n",
       "      <td>140</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-10</th>\n",
       "      <td>32</td>\n",
       "      <td>150</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-11</th>\n",
       "      <td>36</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            price  volume\n",
       "2020-01-08     21     110\n",
       "2020-01-09     22     140\n",
       "2020-01-10     32     150\n",
       "2020-01-11     36      90"
      ]
     },
     "execution_count": 247,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3、重采样 \n",
    "# resample 表示根据日期维度进行数据聚合，可以按照分钟、小时、工作日、周、月、年等来作为日期维度 \n",
    "ts.resample('2W').sum() # 以2周为单位进行汇总 \n",
    "ts.resample('3M').sum().cumsum() # 以季度为单位进行汇总 \n",
    "\n",
    "# 4、DataFrame重采样 \n",
    "d = dict({'price': [10, 11, 9, 13, 14, 18, 17, 19], \n",
    "          'volume': [50, 60, 40, 100, 50, 100, 40, 50], \n",
    "          'week_starting':pd.date_range('24/08/2020',periods=8,freq='W')}) \n",
    "\n",
    "df1 = pd.DataFrame(d) \n",
    "df1.resample('M',on = 'week_starting').apply(np.sum) \n",
    "df1.resample('M',on = 'week_starting').agg({'price':np.mean,'volume':np.sum}) \n",
    "\n",
    "days = pd.date_range('1/8/2020', periods=4, freq='D') \n",
    "data2 = dict({'price': [10, 11, 9, 13, 14, 18, 17, 19], \n",
    "              'volume': [50, 60, 40, 100, 50, 100, 40, 50]}) \n",
    "\n",
    "df2 = pd.DataFrame(data2, index=pd.MultiIndex.from_product([days, ['morning','afternoon']])) \n",
    "\n",
    "df2.resample('D', level=0).sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c8057b7f",
   "metadata": {},
   "source": [
    "## 时区表示"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 249,
   "id": "6e5bf9ae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012-08-01 08:00:00+08:00    0.569481\n",
       "2012-08-02 08:00:00+08:00    0.773110\n",
       "2012-08-03 08:00:00+08:00    1.022273\n",
       "2012-08-04 08:00:00+08:00   -1.191983\n",
       "2012-08-05 08:00:00+08:00    1.252870\n",
       "Freq: D, dtype: float64"
      ]
     },
     "execution_count": 249,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index = pd.date_range('8/1/2012 00:00', periods=5, freq='D') \n",
    "\n",
    "ts = pd.Series(np.random.randn(len(index)), index) \n",
    "\n",
    "import pytz \n",
    "pytz.common_timezones # 常用时区 \n",
    "\n",
    "# 时区表示 \n",
    "ts = ts.tz_localize(tz='UTC') \n",
    "\n",
    "# 转换成其它时区 \n",
    "ts.tz_convert(tz = 'Asia/Shanghai')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "39b220db",
   "metadata": {},
   "source": [
    "# 数据可视化"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "57aceb9f",
   "metadata": {},
   "source": [
    "## 线形图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 250,
   "id": "395acb45",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 250,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAEECAYAAADNv0QiAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAACKz0lEQVR4nO2dd3gURR+A37nLpfdOSCD03ntHilQFRAURwd4L6mdv2LD3jhVFQUQREaUX6b13AoEESO89d7ffH3M1d+kJCbDv8+S53dnZ3bls8tuZXxWKoqCioqKicnmiqesBqKioqKjUHqqQV1FRUbmMUYW8ioqKymWMKuRVVFRULmNUIa+ioqJyGaMKeRUVFZXLGJe6HoAtwcHBSnR0dF0PQ0VFReWSYteuXSmKooQ4O1avhHx0dDQ7d+6s62GoqKioXFIIIc6UdkxV16ioqKhcxqhCXkVFReUyRhXyKioqKpcx9Uon74zi4mLi4+MpKCio66GUi7u7O5GRkeh0uroeioqKigpwCQj5+Ph4fHx8iI6ORghR18MpFUVRSE1NJT4+niZNmtT1cFRUVFSAS0BdU1BQQFBQUL0W8ABCCIKCgi6JFYeKisqVQ70X8kC9F/BmLpVxqqio1FOMRjAaavSSl4SQrw8sWrQIIQRHjx6t66GoqKhcrnw/El4JhILMGrukKuQryLx58+jfvz/z58+v66GoqKhcrsRtk59vNoJfb6mRS6pCvgLk5OSwadMmvv32W1XIq6io1A4Gvf3+kb8g7XS1L1vvvWtseXnJIQ6fz6rRa7aN8OWla9qV2efPP/9k5MiRtGzZksDAQHbv3k3Xrl1rdBwqKipXOKfWOm8LrJ63Xo3N5IUQWiHEHiHE36b9QCHESiHECdNnQE3d62Izb948Jk+eDMDkyZOZN29eHY9IRUXlsiN+BwgN+EVZ2/5+FPSF1bpsTc7kHwGOAL6m/aeB1YqivCmEeNq0/1R1blDejLs2SE1NZc2aNRw8eBAhBAaDASEEb7/9tupNo6KiUjNknoP1b4F/Y/AKgcw4cPWBomxY+aJs73N/lS5dIzN5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
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "# 1、线形图\n",
    "df1 = pd.DataFrame(data = np.random.randn(1000,4),\n",
    "                  index = pd.date_range(start = '27/6/2021',periods=1000),\n",
    "                  columns=list('ABCD'))\n",
    "df1.cumsum().plot()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "08000e53",
   "metadata": {},
   "source": [
    "## 条形图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 251,
   "id": "d2ca70b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.924380</td>\n",
       "      <td>0.699992</td>\n",
       "      <td>0.663103</td>\n",
       "      <td>0.404914</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.594723</td>\n",
       "      <td>0.461117</td>\n",
       "      <td>0.215152</td>\n",
       "      <td>0.741021</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.174709</td>\n",
       "      <td>0.625571</td>\n",
       "      <td>0.669310</td>\n",
       "      <td>0.281076</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.799197</td>\n",
       "      <td>0.370270</td>\n",
       "      <td>0.729255</td>\n",
       "      <td>0.768106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.634416</td>\n",
       "      <td>0.115266</td>\n",
       "      <td>0.378593</td>\n",
       "      <td>0.543379</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.121157</td>\n",
       "      <td>0.439694</td>\n",
       "      <td>0.895943</td>\n",
       "      <td>0.025646</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.435030</td>\n",
       "      <td>0.830365</td>\n",
       "      <td>0.358657</td>\n",
       "      <td>0.021145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.271666</td>\n",
       "      <td>0.638862</td>\n",
       "      <td>0.604671</td>\n",
       "      <td>0.886503</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.853601</td>\n",
       "      <td>0.734007</td>\n",
       "      <td>0.779021</td>\n",
       "      <td>0.083711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.651435</td>\n",
       "      <td>0.911741</td>\n",
       "      <td>0.996347</td>\n",
       "      <td>0.867878</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          A         B         C         D\n",
       "0  0.924380  0.699992  0.663103  0.404914\n",
       "1  0.594723  0.461117  0.215152  0.741021\n",
       "2  0.174709  0.625571  0.669310  0.281076\n",
       "3  0.799197  0.370270  0.729255  0.768106\n",
       "4  0.634416  0.115266  0.378593  0.543379\n",
       "5  0.121157  0.439694  0.895943  0.025646\n",
       "6  0.435030  0.830365  0.358657  0.021145\n",
       "7  0.271666  0.638862  0.604671  0.886503\n",
       "8  0.853601  0.734007  0.779021  0.083711\n",
       "9  0.651435  0.911741  0.996347  0.867878"
      ]
     },
     "execution_count": 251,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 2、条形图\n",
    "df2 = pd.DataFrame(data = np.random.rand(10,4),\n",
    "                   columns = list('ABCD'))\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 252,
   "id": "ced41c9e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 252,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD1CAYAAABA+A6aAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAVAUlEQVR4nO3df5DcdZ3n8efbYTRx4USTQSAhJLJhhWgRcQxwWrcs6+2FLHcUK7UVqCKcVV4qrhRa7l6tuFdr3Kq78qwrrnTjmooHu1InSSlLMOfFRW75oahgfuyQBBMxi2CmEsgQz2SzJEiS9/3R33hj2zPdQ3+nu+c7z0dV13R/v5/5fl6Z9Lzn05/+fL8dmYkkaep7XbcDSJLKYUGXpIqwoEtSRVjQJakiLOiSVBEWdEmqiDO61fHs2bNz/vz53epekqakbdu2vZSZA432da2gz58/n61bt3are0makiLi+bH2NZ1yiYgZEfGDiHgqIp6OiE83aHN1RByOiKHi9ufthpYkTUwrI/RXgGsy82hE9AOPR8Q3M/OJunbfyczryo8oSWpF04KetWsDHC0e9hc3rxcgST2mpTn0iOgDtgG/CXwhM59s0OyqiHgK2A/8SWY+XV5MqbFXX32V4eFhjh8/3u0o45oxYwZz586lv7+/21FUYS0V9Mw8CSyOiLOBjRHxjszcNarJduDCYlpmGfAAsLD+OBGxElgJMG/evDajSzA8PMxZZ53F/PnziYhux2koMzl06BDDw8MsWLCg23FUYRNah56ZPwceBZbWbT+SmUeL+5uB/oiY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IizoklQRFnRJqggLuiRVhAVdkiri/wH1R//XlbMtmgAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df2.plot.bar(stacked = True) # stacked 是否堆叠"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9edbfdfa",
   "metadata": {},
   "source": [
    "## 饼图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 253,
   "id": "118e6723",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([<AxesSubplot:ylabel='One'>, <AxesSubplot:ylabel='Two'>],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": 253,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAdoAAADZCAYAAACHB/G1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAyoklEQVR4nO3deZxT1f3/8ddJMgNM2JUdBAENCkoAgbogbnFpXSpq3dJFWlvTWtvaX7X6rUu6WltrXdqJrR1b0e+3y9ex37rWrRIVUUHBlQEXZN9hZph9Juf3xw06IjCZJPeee28+z8djHtrp5J63MDefnHPPorTWCCGEEMIeAdMBhBBCCD+TQiuEEELYSAqtEEIIYSMptEIIIYSNpNAKIYQQNpJCK4QQQthICq0QQghhIym0QgghhI2k0AohhBA2kkIrhBBC2EgKrRBCCGGjkOkAQuRr8eLFg0Oh0N3AJNz9oTEDvNne3v61adOmbTIdRgg38vP9LIVWeFYoFLp76NChhwwaNGh7IBBw7ekYmUxGbd68+dANGzbcDZxpOo8QbuTn+9nNnxqE6MqkQYMG1bn5pgQIBAJ60KBBtVif1IUQe+bb+1kKrfCygNtvyl2yOeV+E2LvfHs/y40vRIHuvffe/kq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hgDjN7tnyPpYoTi5UG3z3+332Oz9/EjjcCa7NdqrP/OxcArhRxnJYT4pJrKhgDW/I8ZwDis+3osMPav486oz6j20QU2kcHaY3gdsB74kOy9DLydjKVND0+XFCm0PlFT2RDE6vGOwSq++2MtP/jo6/WB99W9OfD+Cqy1wC1YHxrWky2syVh6u4HoQohObnjy2AqsSVXDsv/cD+seDmCt4Q3s9u8KqOPjoroO2CTF1D2k0AohhBA2ki0YhRBCCBtJoRVCCCFsJIVWCCGEsJEUWiGEEMJGUmiFEEIIG0mhFUIIIWwkhVYIIYSwkRRaIYQQwkZSaIUQQggbSaEVQgghbCSFVgghhLCRFFohhBDCRlJohRBCCBtJoRVCCCFsJIVWCCGEsJEUWiGEEMJGUmiFEEIIG0mhFUIIIWwkhVYIIYSwkRRaIYQQwkZSaIUQQggbSaEVQgghbCSFVgghhLCRFFohhBDCRlJohRBCCBtJoRVCCCFs9P8BPLZFZELgTxsAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 576x576 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 3、饼图，百分比，自动计算\n",
    "df3 = pd.DataFrame(data = np.random.rand(4,2),\n",
    "                   index = list('ABCD'),\n",
    "                   columns=['One','Two'])\n",
    "# subplots两个图，多个图\n",
    "# figsize 尺寸\n",
    "df3.plot.pie(subplots = True,figsize = (8,8),colors = np.random.random(size = (4,3)))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a5739f78",
   "metadata": {},
   "source": [
    "## 散点图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 254,
   "id": "fd64e61f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='A', ylabel='B'>"
      ]
     },
     "execution_count": 254,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEGCAYAAABo25JHAAAAOXRFWHRTb2Z0d2Fy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jnjj4iYqe6uqP6FChm/7XFJH5L0QM/mIsa+gL7Gn3Mi2CzpVz33T1XbSrIxIs5I3T+Wkja0HE/tbG+VdIOkx1XQ+KvSyAlJU5KORERJ4/+8pF2Sei9YXMrYpW7Sf8T2cds7q219jb+VC9M0xBfZxrmyGbO9WtJBSR+PiN/YF3sJ5Ckifidpm+23SXrY9rtbDqkRtj8saSoijtu+qeVw2jIRES/Y3iDpiO2n+/0FOR8RnJJ0Vc/9cUkvtBRLW160vUmSqtupluOpje0V6iaBL0fE16vNxYx/TkS8IulRdeeLShj/hKTbbD+nbvl3u+0vqYyxS5Ii4oXqdkrSw+qWxfsaf86J4EeSrrH9Dtt/IOmjkg63HFPTDku6p/r6HkmHWoylNu5+9P83SU9FxL/2/Fcp4x+rjgRk+wpJfyHpaRUw/oj4ZESMR8RWdd/jxyLibhUwdkmy/VbbV859LekDkp5Qn+PPemWx7b9Ut364XNKDEfHZdiOqj+2vSrpJ3Ra0L0r6Z0n/IemApC2Snpd0R0TMn1BOnu33SfovST/TG3XiT6k7T1DC+K9Td0Jwubof7g5ExGdsr1MB459TlYb+KSI+XMrYbf+xukcBUrfU/5WI+Gy/4886EQAAFpdzaQgAsAQkAgAoHIkAAApHIgCAwpEIAKBwJAJgQLb/ynbYflfbsQCXg0QADO4uSY+pu5AJSBbrCIABVH2Nfi7p/ZIORwRHBUgWRwTAYG6X9O2I+B9JL9n+05bjAQZGIgAGc5e6Tc5U3d7VYizAZaE0BPSp6uNySt2OjqFuj5+Q9PbgDYUEcUQA9O9vJD0UEW+PiK0RcZWk/5X0vpbjAgZCIgD6d5fe6Pg456Ckj7UQC3DZKA0BQOE4IgCAwpEIAKBwJAIAKByJAAAKRyIAgMKRCACgcCQCACjc/wPOLYLqc07NbwAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 4、散点图，横纵坐标，表示：两个属性之间的关系\n",
    "df4 = pd.DataFrame(np.random.randint(0,50, size = (50,4)), columns=list('ABCD'))\n",
    "df4.plot.scatter(x='A', y='B') # A和B关系绘制\n",
    "# # 在一张图中绘制AC散点图，同时绘制BD散点图\n",
    "# ax = df4.plot.scatter(x='A', y='C', color='DarkBlue', label='Group 1');\n",
    "# df4.plot.scatter(x='B', y='D', color='DarkGreen', label='Group 2', ax=ax)\n",
    "# # 气泡图，散点有大小之分\n",
    "# df4.plot.scatter(x='A',y='B',s = df4['C']*200)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 255,
   "id": "5c0f8342",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "      <th>F</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>22</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>22</td>\n",
       "      <td>32</td>\n",
       "      <td>46</td>\n",
       "      <td>19</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>24</td>\n",
       "      <td>49</td>\n",
       "      <td>11</td>\n",
       "      <td>40</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>44</td>\n",
       "      <td>4</td>\n",
       "      <td>14</td>\n",
       "      <td>19</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>31</td>\n",
       "      <td>20</td>\n",
       "      <td>3</td>\n",
       "      <td>33</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>4</td>\n",
       "      <td>29</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>14</td>\n",
       "      <td>30</td>\n",
       "      <td>16</td>\n",
       "      <td>29</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>19</td>\n",
       "      <td>15</td>\n",
       "      <td>9</td>\n",
       "      <td>13</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>40</td>\n",
       "      <td>0</td>\n",
       "      <td>20</td>\n",
       "      <td>2</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>24</td>\n",
       "      <td>25</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>43</td>\n",
       "      <td>34</td>\n",
       "      <td>39</td>\n",
       "      <td>15</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>14</td>\n",
       "      <td>49</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>19</td>\n",
       "      <td>30</td>\n",
       "      <td>3</td>\n",
       "      <td>39</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>3</td>\n",
       "      <td>32</td>\n",
       "      <td>23</td>\n",
       "      <td>17</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>19</td>\n",
       "      <td>33</td>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "      <td>-2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>46</td>\n",
       "      <td>35</td>\n",
       "      <td>11</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>36</td>\n",
       "      <td>15</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>29</td>\n",
       "      <td>33</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>43</td>\n",
       "      <td>43</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>12</td>\n",
       "      <td>33</td>\n",
       "      <td>23</td>\n",
       "      <td>3</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>30</td>\n",
       "      <td>19</td>\n",
       "      <td>31</td>\n",
       "      <td>8</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>23</td>\n",
       "      <td>12</td>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>42</td>\n",
       "      <td>35</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>44</td>\n",
       "      <td>1</td>\n",
       "      <td>31</td>\n",
       "      <td>7</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>44</td>\n",
       "      <td>15</td>\n",
       "      <td>26</td>\n",
       "      <td>41</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>34</td>\n",
       "      <td>8</td>\n",
       "      <td>14</td>\n",
       "      <td>30</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>35</td>\n",
       "      <td>20</td>\n",
       "      <td>41</td>\n",
       "      <td>34</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>48</td>\n",
       "      <td>17</td>\n",
       "      <td>30</td>\n",
       "      <td>2</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>23</td>\n",
       "      <td>19</td>\n",
       "      <td>0</td>\n",
       "      <td>35</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>5</td>\n",
       "      <td>8</td>\n",
       "      <td>46</td>\n",
       "      <td>46</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>19</td>\n",
       "      <td>38</td>\n",
       "      <td>19</td>\n",
       "      <td>16</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>48</td>\n",
       "      <td>1</td>\n",
       "      <td>19</td>\n",
       "      <td>35</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>21</td>\n",
       "      <td>41</td>\n",
       "      <td>31</td>\n",
       "      <td>2</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>15</td>\n",
       "      <td>28</td>\n",
       "      <td>16</td>\n",
       "      <td>6</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>26</td>\n",
       "      <td>35</td>\n",
       "      <td>7</td>\n",
       "      <td>13</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>0</td>\n",
       "      <td>46</td>\n",
       "      <td>7</td>\n",
       "      <td>21</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>32</td>\n",
       "      <td>30</td>\n",
       "      <td>4</td>\n",
       "      <td>48</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>42</td>\n",
       "      <td>28</td>\n",
       "      <td>18</td>\n",
       "      <td>17</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "      <td>37</td>\n",
       "      <td>46</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>3</td>\n",
       "      <td>46</td>\n",
       "      <td>30</td>\n",
       "      <td>30</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>29</td>\n",
       "      <td>34</td>\n",
       "      <td>20</td>\n",
       "      <td>43</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>8</td>\n",
       "      <td>18</td>\n",
       "      <td>0</td>\n",
       "      <td>30</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>10</td>\n",
       "      <td>6</td>\n",
       "      <td>27</td>\n",
       "      <td>41</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>29</td>\n",
       "      <td>3</td>\n",
       "      <td>46</td>\n",
       "      <td>42</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>9</td>\n",
       "      <td>43</td>\n",
       "      <td>43</td>\n",
       "      <td>22</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>17</td>\n",
       "      <td>31</td>\n",
       "      <td>13</td>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>17</td>\n",
       "      <td>6</td>\n",
       "      <td>12</td>\n",
       "      <td>23</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>25</td>\n",
       "      <td>25</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>19</td>\n",
       "      <td>37</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>44</td>\n",
       "      <td>28</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     A   B   C   D   F\n",
       "0   22   7   7   6   5\n",
       "1   22  32  46  19  47\n",
       "2   24  49  11  40  15\n",
       "3   44   4  14  19  15\n",
       "4   31  20   3  33   5\n",
       "5    5   9   4  29   2\n",
       "6   14  30  16  29  18\n",
       "7   19  15   9  13   8\n",
       "8   40   0  20   2  16\n",
       "9   24  25  13  12  14\n",
       "10  43  34  39  15  35\n",
       "11  14  49  11  12   9\n",
       "12  19  30   3  39   0\n",
       "13   3  32  23  17  27\n",
       "14  19  33   0  17  -2\n",
       "15  46  35  11   0   9\n",
       "16  36  15   3   8   5\n",
       "17  29  33   2   2   1\n",
       "18  43  43   2   4   2\n",
       "19  12  33  23   3  23\n",
       "20  30  19  31   8  27\n",
       "21  23  12  17   1  12\n",
       "22  42  35  11  11   8\n",
       "23  44   1  31   7  27\n",
       "24  44  15  26  41  26\n",
       "25  34   8  14  30  14\n",
       "26  35  20  41  34  44\n",
       "27  48  17  30   2  33\n",
       "28  23  19   0  35   0\n",
       "29   5   8  46  46  48\n",
       "30  19  38  19  16  15\n",
       "31  48   1  19  35  16\n",
       "32  21  41  31   2  27\n",
       "33  15  28  16   6  20\n",
       "34  26  35   7  13  11\n",
       "35   0  46   7  21   5\n",
       "36  32  30   4  48   5\n",
       "37  42  28  18  17  18\n",
       "38   6   5  37  46  32\n",
       "39   3  46  30  30  30\n",
       "40  29  34  20  43  17\n",
       "41   8  18   0  30   3\n",
       "42  10   6  27  41  30\n",
       "43  29   3  46  42  48\n",
       "44   9  43  43  22  43\n",
       "45  17  31  13   7   9\n",
       "46  17   6  12  23  15\n",
       "47  25  25   4   2  -1\n",
       "48  19  37  13  12  12\n",
       "49  44  28  41  33  43"
      ]
     },
     "execution_count": 255,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df4['F'] = df4['C'].map(lambda x : x + np.random.randint(-5,5,size =1)[0])\n",
    "df4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 256,
   "id": "55525aa1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='C', ylabel='F'>"
      ]
     },
     "execution_count": 256,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
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": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df4.plot.scatter(x = 'C',y = 'F')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dc308e43",
   "metadata": {},
   "source": [
    "## 面积图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 257,
   "id": "636aa4fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAABX/0lEQVR4nO29d5gkZ3Xv/3mrOvfktGk2a6NQRIAkhCVElC5YJloYI+FwsTCYy+/a99rYPwP2fRyur+1rQCAQwWQJERSQhAjKAQntrna1eXc2Tc55OlXVe+4f1bO72p3QPdN56vM88+zOTE3XmZ6ub7913nO+R4kIHh4eHh7lj1HsADw8PDw8coMn6B4eHh4VgifoHh4eHhWCJ+geHh4eFYIn6B4eHh4Vgq9YJ25qapJ169YV6/QeHh4eZcnOnTsHRaR5pu8VTdDXrVvHjh07inV6Dw8Pj7JEKXVqtu95KRcPDw+PCsETdA8PD48KwRN0Dw8PjwqhaDn0mbAsi87OThKJRLFDmZdQKERrayt+v7/YoXh4eHgAJSbonZ2dVFdXs27dOpRSxQ5nVkSEoaEhOjs7Wb9+fbHD8fDw8ABKLOWSSCRobGwsaTEHUErR2NhYFncSHh4eS4eSEnSg5MV8mnKJ08PDY+lQcoLu4eHh4bEwSiqHfi6T/3oApuzcPWDUR9VfbJ/3sHvvvZd3v/vdHDx4kK1bt+bu/B4eHkXjF//j15gBgzf9w+uKHUreKO0Vei7FPIvHu+uuu7jmmmu4++67c3t+Dw+PotC/b5jO5/s49VQPvXsGix1O3ihtQS8Ck5OTPPvss3z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y8kjxLiz4DvpRc/x8m/JUdJIiIvKKV+BOzCrQx7iQq1APBa/z08PDwqhHJLuXh4eHh4zIIn6B4eHh4VgifoHh4eHhWCJ+geHh4eFYIn6B4eHh4VgifoHh4eHhWCJ+geHh4eFcL/A5NZ521yFC7SAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 5、面积图\n",
    "df5 = pd.DataFrame(data = np.random.rand(10, 4), \n",
    "                   columns=list('ABCD'))\n",
    "df5.plot.area(stacked = True,color = np.random.rand(4,3));# stacked 是否堆叠"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 258,
   "id": "29bd363b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.86729674, 0.57501898, 0.50152358],\n",
       "       [0.627469  , 0.05758988, 0.73565595],\n",
       "       [0.83923131, 0.96935882, 0.48494348],\n",
       "       [0.3974718 , 0.10334643, 0.26907695]])"
      ]
     },
     "execution_count": 258,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 颜色：红绿蓝\n",
    "np.random.rand(4,3) # 4行3列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 261,
   "id": "0383966d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>Python</th>\n",
       "      <th>Python等级</th>\n",
       "      <th>Math</th>\n",
       "      <th>En</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>31</td>\n",
       "      <td>不及格</td>\n",
       "      <td>1</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>71</td>\n",
       "      <td>中等</td>\n",
       "      <td>69</td>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>92</td>\n",
       "      <td>优秀</td>\n",
       "      <td>24</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>52</td>\n",
       "      <td>不及格</td>\n",
       "      <td>16</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>85</td>\n",
       "      <td>优秀</td>\n",
       "      <td>95</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0  Python Python等级  Math  En\n",
       "0           0      31      不及格     1  44\n",
       "1           1      71       中等    69  67\n",
       "2           2      92       优秀    24  31\n",
       "3           3      52      不及格    16  56\n",
       "4           4      85       优秀    95  48"
      ]
     },
     "execution_count": 261,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_excel('./data/分数汇总2.xlsx')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 263,
   "id": "b72d8da7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     不\n",
       "1     中\n",
       "2     优\n",
       "3     不\n",
       "4     优\n",
       "5     优\n",
       "6     不\n",
       "7     不\n",
       "8     中\n",
       "9     中\n",
       "10    不\n",
       "11    不\n",
       "12    不\n",
       "13    中\n",
       "14    不\n",
       "15    中\n",
       "16    中\n",
       "17    不\n",
       "18    不\n",
       "19    不\n",
       "20    不\n",
       "21    中\n",
       "22    不\n",
       "23    中\n",
       "24    不\n",
       "25    中\n",
       "26    不\n",
       "27    中\n",
       "28    优\n",
       "29    不\n",
       "Name: Python等级, dtype: object"
      ]
     },
     "execution_count": 263,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Python等级'].str[:1] # 切片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 264,
   "id": "f5658a09",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      0\n",
       "0   NaN\n",
       "1   NaN\n",
       "2   NaN\n",
       "3   NaN\n",
       "4   NaN\n",
       "5   NaN\n",
       "6   NaN\n",
       "7   NaN\n",
       "8   NaN\n",
       "9   NaN\n",
       "10  NaN\n",
       "11  NaN\n",
       "12  NaN\n",
       "13  NaN\n",
       "14  NaN\n",
       "15  NaN\n",
       "16  NaN\n",
       "17  NaN\n",
       "18  NaN\n",
       "19  NaN\n",
       "20  NaN\n",
       "21  NaN\n",
       "22  NaN\n",
       "23  NaN\n",
       "24  NaN\n",
       "25  NaN\n",
       "26  NaN\n",
       "27  NaN\n",
       "28  NaN\n",
       "29  NaN"
      ]
     },
     "execution_count": 264,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 正则表达式 \\d表示数字\n",
    "# .表示任意字符  *表示0个多个\n",
    "df['Python等级'].str.extract(r'.*?(\\d+)')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0d60c6ec",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "322.391px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
